package com.authine.cloudpivot.web.api.controller.base;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.authine.cloudpivot.engine.api.exceptions.ServiceException;
import com.authine.cloudpivot.engine.api.model.application.AppFunctionModel;
import com.authine.cloudpivot.engine.api.model.bizform.BizFormModel;
import com.authine.cloudpivot.engine.api.model.bizmodel.*;
import com.authine.cloudpivot.engine.api.model.bizquery.*;
import com.authine.cloudpivot.engine.api.model.organization.DepartmentModel;
import com.authine.cloudpivot.engine.api.model.organization.UserModel;
import com.authine.cloudpivot.engine.api.model.permission.AppFunctionPermissionModel;
import com.authine.cloudpivot.engine.api.model.permission.AppPackagePermissionModel;
import com.authine.cloudpivot.engine.api.model.permission.PermissionGroupModel;
import com.authine.cloudpivot.engine.api.model.runtime.*;
import com.authine.cloudpivot.engine.api.model.system.RelatedCorpSettingModel;
import com.authine.cloudpivot.engine.api.model.workflow.WorkflowTemplateModel;
import com.authine.cloudpivot.engine.component.query.api.FilterExpression;
import com.authine.cloudpivot.engine.component.query.api.Page;
import com.authine.cloudpivot.engine.component.query.api.helper.PageableImpl;
import com.authine.cloudpivot.engine.component.query.api.helper.Q;
import com.authine.cloudpivot.engine.enums.ErrCode;
import com.authine.cloudpivot.engine.enums.status.SequenceStatus;
import com.authine.cloudpivot.engine.enums.status.UserStatus;
import com.authine.cloudpivot.engine.enums.status.WorkflowInstanceStatus;
import com.authine.cloudpivot.engine.enums.type.*;
import com.authine.cloudpivot.engine.workflow.model.activity.Activity;
import com.authine.cloudpivot.engine.workflow.model.activity.ParticipantActivity;
import com.authine.cloudpivot.engine.workflow.model.data.PropertyPermission;
import com.authine.cloudpivot.web.api.dubbo.DubboConfigService;
import com.authine.cloudpivot.web.api.exception.PortalException;
import com.authine.cloudpivot.web.api.helper.*;
import com.authine.cloudpivot.web.api.view.ResponseResult;
import com.authine.cloudpivot.web.api.view.runtime.*;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.apache.commons.lang3.StringUtils;
import org.apache.curator.shaded.com.google.common.base.Joiner;
import org.apache.curator.shaded.com.google.common.base.Splitter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

/**
 * 查询列表运行时
 *
 * @author zhangjie
 */
@Slf4j
public abstract class BaseQueryRuntimeController extends RuntimeController {

    @Autowired
    private DubboConfigService dubboConfigService;

    //TODO: 评估内存泄露风险
    public static final Map<String, Object> mapFileOperateInfo = new ConcurrentHashMap<>();

    //默认正则表达式，拼接用
    public final static String DEFAULT_REGEX = "^(([%s];){0,%d}[%s])+$";


    @Value("${server.domain:}")
    private String serverDomain;

    @Value("${server.servlet.context-path}")

    private String servletContextPath;

    /**
     * 处理关联数据
     */
    protected void parseRelevanceData(String relevanceInfo, List<BizPropertyModel> bizPropertyModelList, FormDataVO formData) {
        if (CollectionUtils.isEmpty(bizPropertyModelList)) {
            return;
        }

        if (StringUtils.isEmpty(relevanceInfo)) {
            return;
        }

        List<BizPropertyModel> bizPropertyModels = bizPropertyModelList.stream()
                .filter(m -> m.getPublished() && m.getPropertyType().equals(BizPropertyType.WORK_SHEET)).collect(Collectors.toList());

        if (CollectionUtils.isEmpty(bizPropertyModels)) {
            return;
        }
        Map<String, List<BizPropertyModel>> listMap = bizPropertyModels.stream().collect(Collectors.groupingBy(BizPropertyModel::getCode));
        Map<String, Object> map = JSONObject.parseObject(relevanceInfo, Map.class);

        String userId = getUserId();
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            List<BizPropertyModel> propertyModels = listMap.get(entry.getKey());
            if (CollectionUtils.isEmpty(propertyModels)) {
                continue;
            }
            String relativeCode = propertyModels.get(0).getRelativeCode();
            QueryDataVO queryData = new QueryDataVO();
            queryData.setPage(0);
            queryData.setSize(1);
            queryData.setSchemaCode(relativeCode);
            if (StringUtils.isEmpty(relativeCode)) {
                continue;
            }
            queryData.setMobile(false);
            if (entry.getValue() == null) {
                continue;
            }
            queryData.setObjectIds(ImmutableList.of(entry.getValue().toString()));
            //解析表单数据项映射
            List<String> queryCodes = new ArrayList<>();
            parseMappingCodes(entry.getKey(), queryCodes, formData);
            if (CollectionUtils.isNotEmpty(queryCodes)) {
                BizObjectQueryModel.Options options = new BizObjectQueryModel.Options();
                options.setCustomDisplayColumns(queryCodes);
                options.setQueryDisplayType(QueryDisplayType.APPEND);
                queryData.setOptions(options);
            }
            Page<BizObjectModel> bizObject = queryBizObject(userId, queryData, false, true, false);
            if (bizObject == null) {
                continue;
            }
            if (CollectionUtils.isEmpty(bizObject.getContent())) {
                continue;
            }
            formData.getBizObject().getData().put(entry.getKey(), bizObject.getContent().get(0).getData());
        }

    }

    /**
     * 解析映射字段
     *
     * @param queryCodes
     * @param formData
     */
    private void parseMappingCodes(String propertyCode, List<String> queryCodes, FormDataVO formData) {
        if (StringUtils.isEmpty(propertyCode)) {
            return;
        }
        if (formData.getBizSheet() == null) {
            return;
        }
        if (StringUtils.isEmpty(formData.getBizSheet().getPublishedAttributesJson())) {
            return;
        }
        Map map = JSON.parseObject(formData.getBizSheet().getPublishedAttributesJson(), Map.class);
        Map map1 = JSON.parseObject(map.get(propertyCode).toString(), Map.class);
        Map map2 = JSON.parseObject(map1.get("options").toString(), Map.class);
        Object mappings = map2.get("mappings");
        if (mappings == null) {
            return;
        }
        if (mappings instanceof String) {
            if (StringUtils.isEmpty((String) mappings)) {
                return;
            }
            String[] strings = ((String) mappings).split(";");
            for (String string : strings) {
                String[] split = string.split(":");
                queryCodes.add(split[0]);
            }
        }
        if (log.isDebugEnabled()) {
            log.debug("用于查询的值为{}", JSON.toJSONString(queryCodes));
        }
    }

    /**
     * @param userId       用户id
     * @param queryData    查询数据结果
     * @param isExport     是否导出查询
     * @param isAuthFilter 是否查询权限
     * @param isOwner      拥有者修改按钮查询应用列表权限时用的
     * @return data               分页数据
     */
    protected Page<BizObjectModel> queryBizObjects(String userId, QueryDataVO queryData, Boolean isExport, Boolean isAuthFilter, Boolean isOwner) {
        Boolean isMobile = Objects.nonNull(queryData.getMobile()) ? queryData.getMobile() : Boolean.FALSE;
        ClientType clientType = isMobile ? ClientType.APP : ClientType.PC;
        if (StringUtils.isEmpty(queryData.getQueryCode())) {
            List<BizQueryHeaderModel> bizQueryHeaders = Lists.newArrayList();
            //如果列表编码为空则获取默认第一个列表
            List<BizQueryHeaderModel> bizQueryHeadersTmp = getAppManagementFacade().getBizQueryHeaders(queryData.getSchemaCode());
            List<BizQueryHeaderModel> bizQueryHeadersForApp = bizQueryHeadersTmp.stream().filter(t -> Objects.equals(t.getShowOnMobile(), Boolean.TRUE)).collect(Collectors.toList());
            List<BizQueryHeaderModel> bizQueryHeadersForPC = bizQueryHeadersTmp.stream().filter(t -> Objects.equals(t.getShowOnPc(), Boolean.TRUE)).collect(Collectors.toList());
            if (isMobile) {
                //处理历史数据
                if (CollectionUtils.isNotEmpty(bizQueryHeadersForApp)) {
                    bizQueryHeaders.addAll(bizQueryHeadersForApp);
                }
            } else {
                bizQueryHeaders.addAll(bizQueryHeadersForPC);
            }
            queryData.setQueryCode(CollectionUtils.isNotEmpty(bizQueryHeaders) ? bizQueryHeaders.get(0).getCode() : bizQueryHeadersTmp.get(0).getCode());
        }
        String schemaCode = queryData.getSchemaCode();
        BizQueryModel bizQueryModel = getAppManagementFacade().getBizQuery(schemaCode, queryData.getQueryCode(), clientType);
        //生成查询条件方法
        List<FilterVO> filters = queryData.getFilters();
        //过滤关联表单多选查询条件
        List<FilterVO> query = filters.stream().filter(item -> (!BizPropertyType.MULT_WORK_SHEET.equals(item.getPropertyType()))).collect(Collectors.toList());
        queryData.setFilters(query);
        BizObjectQueryModel bizObjectQueryModel = getBizObjectQuerys(userId, queryData, bizQueryModel, isAuthFilter, isOwner);
        //过滤关联表单多选
        List<FilterVO> filterVOS = filters.stream().filter(item -> (BizPropertyType.MULT_WORK_SHEET.equals(item.getPropertyType()))).collect(Collectors.toList());
        List<Map<String, String>> filterStr = Lists.newArrayList();
        for (FilterVO vo : filterVOS) {
            if (StringUtils.isNotEmpty(vo.getValue())) {
                Map<String, String> map = Maps.newHashMap();
                map.put(vo.getPropertyCode(), vo.getValue());
                filterStr.add(map);
            }
        }
        //分页信息
        int page = queryData.getPage() == null ? 0 : queryData.getPage();
        //int page = 0;
        int size = queryData.getSize();
        PageableImpl pageable = null;
        if (isExport) {
            pageable = new PageableImpl(0, size);
        } else if (!CollectionUtils.isEmpty(filterStr)) {
            //当为关联表单多选时，不用PageableImpl作分页
        } else {
            pageable = new PageableImpl(page * size, size);
        }

        bizObjectQueryModel.setPageable(pageable);
        bizObjectQueryModel.setSchemaCode(queryData.getSchemaCode());
        bizObjectQueryModel.setQueryCode(queryData.getQueryCode());
        bizObjectQueryModel.setOptions(queryData.getOptions());
        bizObjectQueryModel.setClientType(clientType);
        bizObjectQueryModel.setDisplay(queryData.getDisplay());
        bizObjectQueryModel.setOrderByFields(queryData.getOrderByFields());
        bizObjectQueryModel.setOrderType(queryData.getOrderType());

        BizObjectQueryModel bizObjectQuery = parseQueries(bizObjectQueryModel, schemaCode);

        //关联表单展示字段
        QueryDataVO.ReverseSchemaParam param = queryData.getReverseSchemaParam();
        if (param != null && queryData.getReverseViewFlag()) {
            BizObjectQueryModel.Options options = bizObjectQuery.getOptions();
            if (options != null && options.getQueryDisplayType() == QueryDisplayType.APPEND) {
                List<String> addColumnList = getRelevanceFormConfigColumn(param.getReverseSchemaCode(), param.getReverseSheetCode(), param.getReverseRelevanceFormCode());
                List<String> customDisplayColumns = bizObjectQuery.getOptions().getCustomDisplayColumns();
                if (CollectionUtils.isNotEmpty(customDisplayColumns)) {
                    customDisplayColumns.addAll(addColumnList);
                } else {
                    bizObjectQuery.getOptions().setCustomDisplayColumns(addColumnList);
                }
            }

        }

        Page<BizObjectModel> data = getBizObjectFacade().queryBizObjectsFilter(bizObjectQuery, filterStr, page, size);
        if (CollectionUtils.isNotEmpty(data.getContent())) {
            List<BizQueryColumnModel> bizQueryColumnModels = bizQueryModel.getQueryColumns();
            parseAddressAndReference(data, bizQueryColumnModels, isExport, queryData.getQueryCode());
            if (isMobile) {
                //处理移动端用户图像
                disposeUserInfo(data);
            } else {
                //处理PC端选人
                parseSpecialProperties(data, isExport);
            }
        }
        return data;
    }

    private List<String> getRelevanceFormConfigColumn(String schemaCode, String sheetCode, String relevanceFormCode) {
        //当前表单
        //BizFormModel bizFormModel = getBizFormModel(schemaCode,queryCode);
        BizFormModel bizFormModel = getAppManagementFacade().getBizForm(schemaCode, sheetCode);

        RelevanceFormHelper helper = new RelevanceFormHelper();
        List<String> showField = helper.getRelevanceFormShowField(bizFormModel, relevanceFormCode);
        String regex = ".";
        String transferRegex = "\\.";
        List<String> configColumnList = Collections.emptyList();
        if (CollectionUtils.isNotEmpty(showField)) {
            List<String> cg = new ArrayList<>();
            List<String> c1 = showField.stream().filter(t -> !t.contains(regex)).collect(Collectors.toList());
            List<String> c2 = showField.stream().filter(t -> t.contains(regex)).collect(Collectors.toList());
            List<String> c3 = c2.stream().map(s -> s.split(transferRegex)[0]).distinct().collect(Collectors.toList());
            cg.addAll(c1);
            cg.addAll(c3);
            configColumnList = cg;
        }
        return configColumnList;
    }


    /**
     * api : 将引用数据项放入查询模型
     * <p>
     * bizObjectQueryModel 中 的Map<String, Object> quotes  里面有三层结构  第一层  key为 模型编码（可以为子表） value为对应该模型编码下的引用的数据项  第二层 key 为关联表单编码 value为该关联表单下的引用数据项 第三层  key为引用的数据项编码 value 为该数据项的几层引用
     *
     * @param bizObjectQueryModel
     * @param schemaCode
     * @return
     */
    private BizObjectQueryModel parseQueries(BizObjectQueryModel bizObjectQueryModel, String schemaCode) {
        BizObjectHelper bizObjectHelper = new BizObjectHelper(getWorkflowInstanceFacade(), getBizObjectFacade(), getOrganizationFacade(), dubboConfigService, getAppManagementFacade(), getSystemManagementFacade());
        Map<String, Map<String, Map<String, List<QuoteModel>>>> object = new HashMap<>();
        Map<String, Map<String, List<QuoteModel>>> quoteModels = bizObjectHelper.parseQuote(schemaCode);

        object.put(schemaCode, quoteModels);
        BizSchemaModel bizSchema = getAppManagementFacade().getBizSchemaBySchemaCode(schemaCode, true);
        List<BizPropertyModel> properties = bizSchema.getProperties();
        List<String> subSchemaCodes = properties.stream().filter(propertyModel -> propertyModel.getPropertyType() == BizPropertyType.CHILD_TABLE).map(BizPropertyModel::getCode).collect(Collectors.toList());
        if (CollectionUtils.isEmpty(subSchemaCodes)) {
            Map<String, Object> result = new HashMap<>(object);
            bizObjectQueryModel.setQuotes(result);
            return bizObjectQueryModel;
        }
        for (String sub : subSchemaCodes) {
            Map<String, Map<String, List<QuoteModel>>> quotes = bizObjectHelper.parseQuote(sub);
            object.put(sub, quotes);
        }
        Map<String, Object> result = new HashMap<>(object);
        bizObjectQueryModel.setQuotes(result);
        return bizObjectQueryModel;
    }

    /**
     * 获取关联查询/反关联列表数据信息
     *
     * @param userId    用户id
     * @param queryData 查询数据结果
     * @return Page
     */
    protected Page<BizObjectModel> queryBizObject(String userId, QueryDataVO queryData, Boolean isExport, Boolean isAuthFilter, Boolean isOwner) {
        Boolean isMobile = Objects.nonNull(queryData.getMobile()) ? queryData.getMobile() : Boolean.FALSE;
        ClientType clientType = isMobile ? ClientType.APP : ClientType.PC;
        if (StringUtils.isEmpty(queryData.getQueryCode())) {
            List<BizQueryHeaderModel> bizQueryHeaders = Lists.newArrayList();
            //如果列表编码为空则获取默认第一个列表
            List<BizQueryHeaderModel> bizQueryHeadersTmp = getAppManagementFacade().getBizQueryHeaders(queryData.getSchemaCode());
            List<BizQueryHeaderModel> bizQueryHeadersForApp = bizQueryHeadersTmp.stream().filter(t -> Objects.equals(t.getShowOnMobile(), Boolean.TRUE)).collect(Collectors.toList());
            List<BizQueryHeaderModel> bizQueryHeadersForPC = bizQueryHeadersTmp.stream().filter(t -> Objects.equals(t.getShowOnPc(), Boolean.TRUE)).collect(Collectors.toList());
            if (isMobile) {
                //处理历史数据
                if (CollectionUtils.isNotEmpty(bizQueryHeadersForApp)) {
                    bizQueryHeaders.addAll(bizQueryHeadersForApp);
                }
            } else {
                bizQueryHeaders.addAll(bizQueryHeadersForPC);
            }
            queryData.setQueryCode(CollectionUtils.isNotEmpty(bizQueryHeaders) ? bizQueryHeaders.get(0).getCode() : bizQueryHeadersTmp.get(0).getCode());
        }
        BizQueryModel bizQueryModel = getAppManagementFacade().getBizQuery(queryData.getSchemaCode(), queryData.getQueryCode(), clientType);
        //生成查询条件方法
        BizObjectQueryModel bizObjectQueryModel = getBizObjectQuery(userId, queryData, bizQueryModel, isAuthFilter, isOwner);
        //分页信息
        int page = queryData.getPage() == null ? 0 : queryData.getPage();
        //int page = 0;
        int size = queryData.getSize();
        PageableImpl pageable = null;
        if (isExport) {
            pageable = new PageableImpl(0, size);
        } else {
            pageable = new PageableImpl(page * size, size);
        }


        bizObjectQueryModel.setPageable(pageable);
        bizObjectQueryModel.setSchemaCode(queryData.getSchemaCode());
        bizObjectQueryModel.setQueryCode(queryData.getQueryCode());
        bizObjectQueryModel.setOptions(queryData.getOptions());
        bizObjectQueryModel.setClientType(clientType);

        bizObjectQueryModel.setDisplay(queryData.getDisplay());
        Page<BizObjectModel> data = getBizObjectFacade().queryBizObjects(bizObjectQueryModel);
        if (CollectionUtils.isNotEmpty(data.getContent())) {
            List<BizQueryColumnModel> bizQueryColumnModels = bizQueryModel.getQueryColumns();
            parseAddressAndReference(data, bizQueryColumnModels, isExport, queryData.getQueryCode());
            if (isMobile) {
                //处理移动端用户图像
                disposeUserInfo(data);
            } else {
                //处理PC端选人
                parseSpecialProperties(data, isExport);
            }
        }
        return data;
    }

    /**
     * 获取子表数字表达格式
     *
     * @param
     */

    protected Map<String, Map<String, Object>> queryChildNumricalFormat(String userId, QueryDataVO queryData, Boolean isExport, Boolean isAuthFilter, List<BizPropertyModel> properties, List<BizQueryColumnModel> columns) {
        long start = System.currentTimeMillis();
        Boolean isMobile = Objects.nonNull(queryData.getMobile()) ? queryData.getMobile() : Boolean.FALSE;
        ClientType clientType = isMobile ? ClientType.APP : ClientType.PC;
        if (StringUtils.isEmpty(queryData.getQueryCode())) {
            List<BizQueryHeaderModel> bizQueryHeaders = Lists.newArrayList();
            //如果列表编码为空则获取默认第一个列表
            List<BizQueryHeaderModel> bizQueryHeadersTmp = getAppManagementFacade().getBizQueryHeaders(queryData.getSchemaCode());
            List<BizQueryHeaderModel> bizQueryHeadersForApp = bizQueryHeadersTmp.stream().filter(t -> Objects.equals(t.getShowOnMobile(), Boolean.TRUE)).collect(Collectors.toList());
            List<BizQueryHeaderModel> bizQueryHeadersForPC = bizQueryHeadersTmp.stream().filter(t -> Objects.equals(t.getShowOnPc(), Boolean.TRUE)).collect(Collectors.toList());
            if (isMobile) {
                //处理历史数据
                if (CollectionUtils.isNotEmpty(bizQueryHeadersForApp)) {
                    bizQueryHeaders.addAll(bizQueryHeadersForApp);
                }
            } else {
                bizQueryHeaders.addAll(bizQueryHeadersForPC);
            }
            queryData.setQueryCode(CollectionUtils.isNotEmpty(bizQueryHeaders) ? bizQueryHeaders.get(0).getCode() : bizQueryHeadersTmp.get(0).getCode());
        }
        BizQueryModel bizQueryModel = getAppManagementFacade().getBizQuery(queryData.getSchemaCode(), queryData.getQueryCode(), clientType);

        //分页信息
        int page = queryData.getPage() == null ? 0 : queryData.getPage();
        int size = queryData.getSize();
        PageableImpl pageable = null;
        if (isExport) {
            pageable = new PageableImpl(page * size, size);
        } else {
            pageable = new PageableImpl(page * size, size);
        }
        //生成查询条件方法
        BizObjectQueryModel bizObjectQueryModel = getBizObjectQuery(userId, queryData, bizQueryModel, isAuthFilter, false);
        bizObjectQueryModel.setPageable(pageable);
        bizObjectQueryModel.setSchemaCode(queryData.getSchemaCode());
        bizObjectQueryModel.setQueryCode(queryData.getQueryCode());
        bizObjectQueryModel.setOptions(queryData.getOptions());
        bizObjectQueryModel.setClientType(clientType);

        return getBizObjectFacade().queryChildNumricalFormat(bizObjectQueryModel, properties, queryData.getMobile(), columns, userId);
    }


    /**
     * 获取导出的数据bizObjects
     */
    protected Page<BizObjectModel> queryExportDatas(String userId, QueryDataVO queryData, Boolean isExport, Boolean isAuthFilter, List<BizPropertyModel> properties, List<BizQueryColumnModel> columns, Map<String, Map<String, Object>> childNumricalFormat) {
        long start = System.currentTimeMillis();
        Boolean isMobile = Objects.nonNull(queryData.getMobile()) ? queryData.getMobile() : Boolean.FALSE;
        ClientType clientType = isMobile ? ClientType.APP : ClientType.PC;
        if (StringUtils.isEmpty(queryData.getQueryCode())) {
            List<BizQueryHeaderModel> bizQueryHeaders = Lists.newArrayList();
            //如果列表编码为空则获取默认第一个列表
            List<BizQueryHeaderModel> bizQueryHeadersTmp = getAppManagementFacade().getBizQueryHeaders(queryData.getSchemaCode());
            List<BizQueryHeaderModel> bizQueryHeadersForApp = bizQueryHeadersTmp.stream().filter(t -> Objects.equals(t.getShowOnMobile(), Boolean.TRUE)).collect(Collectors.toList());
            List<BizQueryHeaderModel> bizQueryHeadersForPC = bizQueryHeadersTmp.stream().filter(t -> Objects.equals(t.getShowOnPc(), Boolean.TRUE)).collect(Collectors.toList());
            if (isMobile) {
                //处理历史数据
                if (CollectionUtils.isNotEmpty(bizQueryHeadersForApp)) {
                    bizQueryHeaders.addAll(bizQueryHeadersForApp);
                }
            } else {
                bizQueryHeaders.addAll(bizQueryHeadersForPC);
            }
            queryData.setQueryCode(CollectionUtils.isNotEmpty(bizQueryHeaders) ? bizQueryHeaders.get(0).getCode() : bizQueryHeadersTmp.get(0).getCode());
        }
        BizQueryModel bizQueryModel = getAppManagementFacade().getBizQuery(queryData.getSchemaCode(), queryData.getQueryCode(), clientType);

        //分页信息
        int page = queryData.getPage() == null ? 0 : queryData.getPage();
        int size = queryData.getSize();
        PageableImpl pageable;
        if (isExport) {
            pageable = new PageableImpl(page * size, size);
        } else {
            pageable = new PageableImpl(page * size, size);
        }
        //生成查询条件方法
        BizObjectQueryModel bizObjectQueryModel = getBizObjectQuery(userId, queryData, bizQueryModel, isAuthFilter, false);
        bizObjectQueryModel.setPageable(pageable);
        bizObjectQueryModel.setSchemaCode(queryData.getSchemaCode());
        bizObjectQueryModel.setQueryCode(queryData.getQueryCode());
        bizObjectQueryModel.setOptions(queryData.getOptions());
        bizObjectQueryModel.setClientType(clientType);
        Page<BizObjectModel> data = getBizObjectFacade().queryExportDatas(bizObjectQueryModel, properties, queryData.getMobile(), columns, userId, childNumricalFormat);
        long end = System.currentTimeMillis();
        log.info("查询：--{}", end - start);
        if (CollectionUtils.isNotEmpty(data.getContent())) {
            List<BizQueryColumnModel> bizQueryColumnModels = bizQueryModel.getQueryColumns();
            if (isMobile) {
                //处理移动端用户图像
                disposeUserInfo(data);
            } else {
                //处理PC端选人
                parseSpecialProperties(data, false);
            }
        }
        long masche = System.currentTimeMillis();
        log.info("处理；--{}", masche - end);
        return data;
    }

    /**
     * 处理位置信息
     */
    protected void parseAddressAndReference(Page<BizObjectModel> data, List<BizQueryColumnModel> columnModels, Boolean isExport, String queryCode) {
        if (CollectionUtils.isEmpty(columnModels) || CollectionUtils.isEmpty(data.getContent())) {
            return;
        }
        if (isExport) {
            //获取模板信息
            List<BizQueryColumnModel> collect = columnModels.stream().filter(t -> t.getPropertyType().equals(BizPropertyType.NUMERICAL)).collect(Collectors.toList());
            Map<String, String> mapTemp = new HashMap<>();
            if (CollectionUtils.isNotEmpty(collect)) {
                BizQueryModel bizQuery = getAppManagementFacade().getBizQuery(columnModels.get(0).getSchemaCode(), queryCode, ClientType.PC);
                String formCode = null;
                if (bizQuery != null && CollectionUtils.isNotEmpty(bizQuery.getQueryActions())) {
                    BizQueryActionModel bizQueryAction = bizQuery.getQueryActions().stream().filter(t -> t.getQueryActionRelativeType() != null && t.getQueryActionRelativeType().equals(QueryActionRelativeType.BIZSHEET) && StringUtils.isNotEmpty(t.getRelativeCode())).findAny().orElse(null);
                    if (bizQueryAction != null) {
                        formCode = bizQueryAction.getRelativeCode();
                        log.debug("获取到的表单编码为{}", formCode);
                    }
                }
                if (StringUtils.isEmpty(formCode)) {
                    formCode = getAppManagementFacade().getBizForms(columnModels.get(0).getSchemaCode()).get(0).getCode();
                }
                BizFormModel sheetModel = getAppManagementFacade().getBizForm(columnModels.get(0).getSchemaCode(), formCode);
                Map map = JSON.parseObject(sheetModel.getPublishedAttributesJson(), Map.class);
                for (BizQueryColumnModel bizQueryColumnModel : collect) {
                    if (map.keySet().contains(bizQueryColumnModel.getPropertyCode())) {
                        Map map1 = JSON.parseObject(map.get(bizQueryColumnModel.getPropertyCode()).toString(), Map.class);
                        Map map2 = JSON.parseObject(map1.get("options").toString(), Map.class);
                        mapTemp.put(bizQueryColumnModel.getPropertyCode(), map2.get("format").toString());
                    }
                }
                log.debug("获取到的表单编码为{}", formCode);

            }
            columnModels = columnModels.stream().filter(t -> t.getPropertyType().equals(BizPropertyType.ADDRESS) || t.getPropertyType().equals(BizPropertyType.WORK_SHEET) || t.getPropertyType().equals(BizPropertyType.NUMERICAL)).collect(Collectors.toList());
            for (BizQueryColumnModel columnModel : columnModels) {
                for (BizObjectModel bizObjectModel : data.getContent()) {
                    if (columnModel.getPropertyType().equals(BizPropertyType.ADDRESS)) {
                        String json = null;
                        if (bizObjectModel.get(columnModel.getPropertyCode()) != null) {
                            json = bizObjectModel.get(columnModel.getPropertyCode()).toString();
                        }
                        if ("{}".equals(json)) {
                            json = null;
                            bizObjectModel.put(columnModel.getPropertyCode(), null);
                            log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>NO.23>>>>" + "json为null");
                        }
                        if (StringUtils.isNotEmpty(json)) {
                            Map map = JSONObject.parseObject(json, Map.class);
                            String name = "";
                            if (map.get("provinceName") != null) {
                                name = name + map.get("provinceName");
                            }
                            if (map.get("cityName") != null) {
                                name = name + map.get("cityName");
                            }
                            if (map.get("districtName") != null) {
                                name = name + map.get("districtName");
                            }
                            if (map.get("address") != null) {
                                name = name + map.get("address");
                            }
                            log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>NO.33>>>>" + name);
                            bizObjectModel.put(columnModel.getPropertyCode(), name);
                        }
                    }
                    if (columnModel.getPropertyType().equals(BizPropertyType.WORK_SHEET)) {
                        if (bizObjectModel.get(columnModel.getPropertyCode()) != null) {
                            Object o = bizObjectModel.get(columnModel.getPropertyCode());
                            //修改:
                            bizObjectModel.put(columnModel.getPropertyCode(), o == "null" ? null : o);
                            log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>NO.43>>>>" + o);
                        }
                    }
                    if (columnModel.getPropertyType().equals(BizPropertyType.NUMERICAL)) {
                        if (bizObjectModel.get(columnModel.getPropertyCode()) == null) {
                            continue;
                        }
                        DecimalFormat df = null;
                        switch (mapTemp.get(columnModel.getPropertyCode())) {

                            case "integer":
                                df = new DecimalFormat("#");
                                bizObjectModel.put(columnModel.getPropertyCode(), df.format(bizObjectModel.get(columnModel.getPropertyCode())));
                                break;
                            case "tenths":
                                df = new DecimalFormat("###,###.#");
                                bizObjectModel.put(columnModel.getPropertyCode(), df.format(bizObjectModel.get(columnModel.getPropertyCode())));
                                break;
                            case "percentile":
                                df = new DecimalFormat("###,###.##");
                                bizObjectModel.put(columnModel.getPropertyCode(), df.format(bizObjectModel.get(columnModel.getPropertyCode())));
                                break;
                            case "ratio":
                                df = new DecimalFormat("#%");
                                BigDecimal ratioResult = (BigDecimal) bizObjectModel.get(columnModel.getPropertyCode());
                                bizObjectModel.put(columnModel.getPropertyCode(), df.format(ratioResult.longValue() / 100.0));
                                break;
                            case "ratio.tenths":
                                df = new DecimalFormat("##.#" + "%");
                                BigDecimal ratioTenths = (BigDecimal) bizObjectModel.get(columnModel.getPropertyCode());
                                bizObjectModel.put(columnModel.getPropertyCode(), df.format(ratioTenths.longValue() / 100.0));
                                break;
                            case "ratio.percentile":
                                df = new DecimalFormat("##.##" + "%");
                                BigDecimal ratioPercentile = (BigDecimal) bizObjectModel.get(columnModel.getPropertyCode());
                                bizObjectModel.put(columnModel.getPropertyCode(), df.format(ratioPercentile.longValue() / 100.0));
                                break;
                            case "HK.percentile":
                                df = new DecimalFormat("HK$#,###.00");
                                bizObjectModel.put(columnModel.getPropertyCode(), df.format(bizObjectModel.get(columnModel.getPropertyCode())));
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
        }
    }

    /**
     * 设置用户显示图像
     *
     * @param data 分页数据
     */
    private void disposeUserInfo(Page<BizObjectModel> data) {
        if (CollectionUtils.isEmpty(data.getContent())) {
            return;
        }
        for (BizObjectModel bizObject : data.getContent()) {
            List<SelectionValue> selectionValues = (List<SelectionValue>) bizObject.get(DefaultPropertyType.CREATER.getCode());
            if (CollectionUtils.isNotEmpty(selectionValues)) {
                bizObject.put("imgUrl", selectionValues.get(0).getImgUrl());
                bizObject.put("originator", selectionValues.get(0).getName());
            }
        }
    }

    private List<String> getPropertyCodeList(BizObjectModel objectModel, BizPropertyType propertyType) {
        BizSchemaModel bizSchema = getAppManagementFacade().getBizSchemaBySchemaCode(objectModel.getSchemaCode());
        List<BizPropertyModel> bizPropertyModels = bizSchema.getProperties().stream().filter(t -> t.getPropertyType().equals(propertyType)).collect(Collectors.toList());
        if (CollectionUtils.isNotEmpty(bizPropertyModels)) {
            return bizPropertyModels.stream().map(BizPropertyModel::getCode).collect(Collectors.toList());
        }
        return Collections.emptyList();
    }

    /**
     * 处理PC端选人控件展示
     *
     * @param data 分页数据
     */
    private void parseSpecialProperties(Page<BizObjectModel> data, Boolean isExport) {
        //获选人数据项
        BizObjectModel objectModel = data.getContent().get(0);
        BizSchemaModel bizSchema = getAppManagementFacade().getBizSchemaBySchemaCode(objectModel.getSchemaCode());
        if (isExport) {
            List<String> selectCodes = getPropertyCodeList(objectModel, BizPropertyType.SELECTION);
            if (CollectionUtils.isEmpty(selectCodes)) {
                return;
            }
            if (log.isDebugEnabled()) {
                log.debug("需要处理的选人数据项为{}", JSON.toJSONString(selectCodes));
            }
            Set<String> dataCodes = null;
            for (String selectCode : selectCodes) {
                for (BizObjectModel bizObject : data.getContent()) {
                    if (CollectionUtils.isEmpty(dataCodes)) {
                        dataCodes = bizObject.getData().keySet();
                        if (log.isDebugEnabled()) {
                            log.debug("需要展示的数据项为{}", JSON.toJSONString(dataCodes));
                        }
                    }
                    if (!dataCodes.contains(selectCode)) {
                        if (log.isDebugEnabled()) {
                            log.debug("不需要展示的选人数据项为{}", selectCode);
                        }
                        break;
                    }
                    if (bizObject.get(selectCode) == null) {
                        continue;
                    }
                    List<SelectionValue> selectionValues = (List<SelectionValue>) bizObject.get(selectCode);
                    bizObject.put(selectCode, getUserNames(selectionValues));
                }
            }
            //处理单据状态
            if (data.getContent().get(0).getData().keySet().contains(DefaultPropertyType.SEQUENCE_STATUS.getCode())) {
                for (BizObjectModel bizObjectModel : data.getContent()) {
                    bizObjectModel.put(DefaultPropertyType.SEQUENCE_STATUS.getCode(), parseSequenceStatus(bizObjectModel));
                }
            }
            //获取逻辑型
            List<BizPropertyModel> logicalModels = bizSchema.getProperties().stream().filter(t -> t.getPropertyType().equals(BizPropertyType.LOGICAL)).collect(Collectors.toList());
            if (CollectionUtils.isNotEmpty(logicalModels)) {
                List<String> logicals = logicalModels.stream().map(BizPropertyModel::getCode).collect(Collectors.toList());
                Set<String> logicalDataCodes = null;
                for (String logical : logicals) {
                    for (BizObjectModel bizObjectModel : data.getContent()) {
                        if (CollectionUtils.isEmpty(logicalDataCodes)) {
                            logicalDataCodes = bizObjectModel.getData().keySet();
                        }
                        if (!logicalDataCodes.contains(logical)) {
                            break;
                        }
                        if (bizObjectModel.get(logical) == null) {
                            continue;
                        }
                        bizObjectModel.put(logical, disposeLogic(bizObjectModel.getString(logical)));
                    }

                }
            }
        }

    }

    /**
     * 处理审批意见
     *
     * @param logic
     * @return
     */
    public Object disposeLogic(String logic) {
        switch (logic) {
            case "1":
                return "是";
            case "0":
                return "否";
            case "true":
                return "是";
            case "false":
                return "否";
            default:
                return "";
        }
    }

    /**
     * 处理单据状态
     *
     * @param bizObjectModel
     * @return
     */
    private Object parseSequenceStatus(BizObjectModel bizObjectModel) {
        switch (bizObjectModel.get(DefaultPropertyType.SEQUENCE_STATUS.getCode()).toString()) {
            case "DRAFT":
                return SequenceStatus.DRAFT.getName();
            case "PROCESSING":
                return SequenceStatus.PROCESSING.getName();
            case "CANCELLED":
                return SequenceStatus.CANCELLED.getName();
            case "COMPLETED":
                return SequenceStatus.COMPLETED.getName();
            default:
                return null;
        }
    }

    /**
     * 从列表数据中获取到用户名
     *
     * @return Object
     */
    public Object getUserNames(List<SelectionValue> selectionValues) {
        if (selectionValues == null) {
            return "";
        }
        return selectionValues.stream().map(SelectionValue::getName).collect(Collectors.joining(", "));
    }

    /**
     * 处理子表导出用户和部门信息
     *
     * @return
     */
    public Object getUserAndDepartNames(List<SelectionValue> selectionValues) {
        List<SelectionValue> departValues = selectionValues.stream().filter(t -> t.getType().equals(UnitType.DEPARTMENT)).collect(Collectors.toList());
        List<SelectionValue> userValues = selectionValues.stream().filter(t -> t.getType().equals(UnitType.USER)).collect(Collectors.toList());
        StringBuilder name = new StringBuilder();
        if (CollectionUtils.isNotEmpty(userValues)) {
            name.append(selectionValues.stream().map(SelectionValue::getName).collect(Collectors.joining(";")));
        }
        if (CollectionUtils.isNotEmpty(departValues)) {
            List<String> collect = departValues.stream().map(SelectionValue::getId).collect(Collectors.toList());
            for (SelectionValue departValue : departValues) {
                Map<String, String> mapDepart = getOrganizationFacade().getParentDepartNamesById(departValue.getId());
                if (mapDepart == null) {
                    continue;
                }
                for (Map.Entry<String, String> entry : mapDepart.entrySet()) {
                    if (!collect.contains(entry.getKey())) {
                        continue;
                    }
                    if (StringUtils.isEmpty(name)) {
                        name.append(entry.getValue());
                    } else {
                        name.append(";").append(entry.getValue());
                    }
                }
            }
        }
        return name;
    }

    /**
     * 获取列表配置信息
     *
     * @param schemaCode 业务模型编码
     * @param queryCode  查询编码
     * @return BizQueryModel
     */
    protected BizQueryModel getBizQuery(String schemaCode, String queryCode, ClientType clientType) {
        validateNotEmpty(schemaCode, "模型编码不能为空");
        if (StringUtils.isEmpty(queryCode)) {
            List<BizQueryHeaderModel> bizQueryHeaders = getAppManagementFacade().getBizQueryHeaders(schemaCode);
            queryCode = bizQueryHeaders == null ? null : bizQueryHeaders.get(0).getCode();
        }
        validateNotEmpty(queryCode, "查询列表编码不能为空");
        //获取列表后台配置信息
        return getAppManagementFacade().getBizQuery(schemaCode, queryCode, clientType);
    }

    /**
     * 批量导入列表数据
     *
     * @param fileName   文件名称
     * @param schemaCode 业务模型编码
     * @param queryCode  查询编码
     * @return FileOperationResult
     */
    protected FileOperationResult importDatas(String userId, String fileName, String schemaCode, String queryCode, String queryField) {
        mapFileOperateInfo.remove(userId);

        log.debug("开始解析文件");
        FileOperationResult result = new FileOperationResult();
        //原有获取文件格式逻辑在文件名带有点号(例如2.3.xls)时校验错误
        String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);
        boolean equals = Objects.equals("xlsx", fileExtension);
        boolean equals1 = Objects.equals("xls", fileExtension);
        if (!(equals || equals1)) {
            result.setErrorType(2);
            result.setOperationResult(true);

            mapFileOperateInfo.put(userId, result);
            return result;
        }

        BizSchemaModel bizSchemaModel = getAppManagementFacade().getBizSchemaBySchemaCode(schemaCode, true);

        //固定表头加载顺序，先加载非子表数据项->无内容的子表数据项->有内容的子表数据项
        List<BizQueryColumnModel> columns = getColumns(bizSchemaModel);

        List<BizPropertyModel> propertyList = bizSchemaModel.getProperties();

        List<BizQueryColumnModel> headerColumns = getHeaderColumns(columns);

        List<BizPropertyType> propertyTypes = columns.stream().map(BizQueryColumnModel::getPropertyType).collect(Collectors.toList());
        //获取配置的数据项信息
        List<String> propertyCode = columns.stream().map(BizQueryColumnModel::getPropertyCode).collect(Collectors.toList());

        List<Map<String, Object>> dataMaps = FileOperateHelper.getMainImportDatas(fileName, headerColumns, propertyCode);
        if (CollectionUtils.isEmpty(dataMaps) || dataMaps.size() < 1) {
            result.setOperationResult(true);
            result.setSuccessCount(0);
            result.setErrorCount(0);
            result.setErrorType(7);
            mapFileOperateInfo.put(userId, result);
            return result;
        }

        if (dataMaps.size() == 1 && dataMaps.get(0).get("success") != null && dataMaps.get(0).get("success").equals(false)) {
            result.setOperationResult(true);
            result.setErrorType(Integer.valueOf(dataMaps.get(0).get("type").toString()));
            Map<String, Object> objectMap = dataMaps.get(0);
            Integer integer = Objects.isNull(objectMap.get("importSize")) ? Integer.valueOf("500") : Integer.valueOf(objectMap.get("importSize").toString());
            result.setImportSize(integer);
            mapFileOperateInfo.put(userId, result);
            return result;
        }
        log.info("導入數據條數：size={}", dataMaps.size());
        //获取数据
        List<String> headers = headerColumns.stream().map(BizQueryColumnModel::getName).collect(Collectors.toList());
        result = disposeData(userId, schemaCode, dataMaps, propertyTypes, headers, propertyList, null, queryField, headerColumns, queryCode);
        return result;
    }

    //固定表头加载顺序，先加载非子表数据项->无内容的子表数据项->有设置内容的子表数据项
    protected List<BizQueryColumnModel> getColumns(BizSchemaModel bizSchemaModel) {
        List<BizPropertyModel> propertyList = bizSchemaModel.getProperties();
        List<BizPropertyModel> properties = Lists.newArrayList();
        properties.addAll(propertyList);

        List<BizQueryColumnModel> columns = new LinkedList<>();
        //1.先将非子表数据项的属性赋给columns
        List<BizPropertyModel> collect = properties.stream().filter(propertyModel -> !Objects.equals(propertyModel.getPropertyType(), BizPropertyType.CHILD_TABLE)).collect(Collectors.toList());
        for (BizPropertyModel propertyModel : collect) {
            BizQueryColumnModel column = parseBizPropertyModel(propertyModel);
            columns.add(column);
        }
        //2.去掉非子表数据项
        properties.removeAll(collect);

        if (CollectionUtils.isEmpty(properties)) {
            return columns;
        }
        //3. columns中加入子表数据项并且该子表数据项无所属数据项
        List<BizPropertyModel> list = Lists.newArrayList();
        for (BizPropertyModel propertyModel : properties) {
            String code = propertyModel.getCode();
            BizSchemaModel bizSchemaBySchemaCode = getAppManagementFacade().getBizSchemaBySchemaCode(code);
            List<BizPropertyModel> childProperties = bizSchemaBySchemaCode.getProperties();
            if (CollectionUtils.isEmpty(childProperties)) {
                list.add(propertyModel);
                BizQueryColumnModel column = parseBizPropertyModel(propertyModel);
                columns.add(column);
                continue;
            }
            List<BizPropertyModel> childPropertyModels = childProperties.stream().filter(childProperty -> !childProperty.getDefaultProperty()).collect(Collectors.toList());
            if (CollectionUtils.isEmpty(childPropertyModels) || childPropertyModels.size() < 1) {
                list.add(propertyModel);
                BizQueryColumnModel column = parseBizPropertyModel(propertyModel);
                columns.add(column);
            }
        }
        properties.removeAll(list);
        //4.columns中加入子表数据项并且里面含有数据项
        if (CollectionUtils.isEmpty(properties)) {
            return columns;
        }
        for (BizPropertyModel propertyModel : properties) {
            BizQueryColumnModel column = parseBizPropertyModel(propertyModel);
            columns.add(column);
        }
        return columns;
    }

    //将数据项中子表数据项属性赋给BizQueryColumnModel和BizQueryChildColumnModel;
    protected BizQueryColumnModel parseBizPropertyModel(BizPropertyModel propertyModel) {
        if (null == propertyModel) {
            return null;
        }
        BizQueryColumnModel column = new BizQueryColumnModel();
        column.setPropertyCode(propertyModel.getCode());
        column.setDefaultProperty(propertyModel.getDefaultProperty());
        column.setName(propertyModel.getName());
        column.setName_i18n(propertyModel.getName_i18n());
        column.setPropertyType(propertyModel.getPropertyType());
        column.setRelativeSchemaCode(propertyModel.getRelativeCode());
        column.setSchemaCode(propertyModel.getSchemaCode());
        column.setSortKey(propertyModel.getSortKey());
        column.setId(propertyModel.getId());
        column.setDeleted(propertyModel.getDeleted());
        if (Objects.equals(column.getPropertyType(), BizPropertyType.CHILD_TABLE)) {
            if (CollectionUtils.isEmpty(column.getChildColumns()) || column.getChildColumns().size() < 1) {
                column.setChildColumns(Lists.newArrayList());
            }
            String code = column.getPropertyCode();
            BizSchemaModel bizSchemaModel = getAppManagementFacade().getBizSchemaBySchemaCode(code, true);
            List<BizPropertyModel> properties = bizSchemaModel.getProperties();
            List<BizQueryChildColumnModel> childColumns = Lists.newArrayList();
            if (CollectionUtils.isNotEmpty(properties)) {
                for (BizPropertyModel propertyModel1 : properties) {
                    String name = propertyModel1.getName();
                    boolean equals = Objects.equals(name, "子表业务对象ID");
                    boolean equals1 = Objects.equals(name, "子表业务对象父类ID");
                    boolean equals2 = Objects.equals(name, "子表排序号");
                    boolean equals3 = Objects.equals(propertyModel1.getPropertyType(), BizPropertyType.COMMENT);
                    boolean equals4 = Objects.equals(propertyModel1.getPropertyType(), BizPropertyType.ATTACHMENT);
                    boolean equals5 = Objects.equals(propertyModel1.getPropertyType(), BizPropertyType.ADDRESS);
                    boolean equals6 = Objects.equals(propertyModel1.getCode(), DefaultSubPropertyType.MODIFIED_TIME.getCode());
                    boolean equals7 = Objects.equals(propertyModel1.getCode(), DefaultSubPropertyType.MODIFIER.getCode());
                    if (equals || equals1 || equals2 || equals3 || equals4 || equals5 || equals6 || equals7) {
                        continue;
                    }
                    BizQueryChildColumnModel columnModel = new BizQueryChildColumnModel();
                    columnModel.setPropertyCode(propertyModel1.getCode());
                    columnModel.setName(propertyModel1.getName());
                    columnModel.setName_i18n(propertyModel1.getName_i18n());
                    columnModel.setPropertyType(propertyModel1.getPropertyType());
                    columnModel.setRelativeSchemaCode(propertyModel1.getRelativeCode());
                    columnModel.setSchemaCode(propertyModel1.getSchemaCode());
                    columnModel.setSortKey(propertyModel1.getSortKey());
                    columnModel.setId(propertyModel1.getId());
                    columnModel.setDeleted(propertyModel1.getDeleted());
                    childColumns.add(columnModel);
                }
                column.setChildColumns(childColumns);
            }

        }
        return column;
    }

    /**
     * 获取列表导出数据的表头信息
     *
     * @param columns 展示字段
     * @return List
     */
    protected List<String> getHeaders(List<BizQueryColumnModel> columns) {
        List<String> headers = new ArrayList<>();
        for (int i = 0; i < columns.size(); i++) {
            BizQueryColumnModel column = columns.get(i);
            //附件、图片、地址、地图定位：不支持导入，导入模板中过滤掉该字段
            if (BizPropertyType.ATTACHMENT.equals(column.getPropertyType())
                    || BizPropertyType.COMMENT.equals(column.getPropertyType())
                    || BizPropertyType.ADDRESS.equals(column.getPropertyType())
                    || BizPropertyType.CHILD_TABLE.equals(column.getPropertyType())) {
                columns.remove(column);
                //不减1会跳过下一个
                i--;
                continue;
            }
            //导入模板过滤掉系统字段，例外（数据标题、单据号作为覆盖导入查询条件，拥有者、拥有者部门产品要求可修改）2019年8月21日15:12:21
            String propertyCode = column.getPropertyCode();
            switch (propertyCode) {
                //业务对象ID
                case "id":
                    columns.remove(column);
                    i--;
                    continue;
                    //创建人
                case "creater":
                    columns.remove(column);
                    i--;
                    continue;
                    //创建人部门
                case "createdDeptId":
                    columns.remove(column);
                    i--;
                    continue;
                    //拥有者部门
                case "ownerDeptId":
                    columns.remove(column);
                    i--;
                    continue;
                    //创建时间
                case "createdTime":
                    columns.remove(column);
                    i--;
                    continue;
                    //修改人
                case "modifier":
                    columns.remove(column);
                    i--;
                    continue;
                    //修改时间
                case "modifiedTime":
                    columns.remove(column);
                    i--;
                    continue;
                    //流程实例ID
                case "workflowInstanceId":
                    columns.remove(column);
                    i--;
                    continue;
                    //单据状态
                case "sequenceStatus":
                    columns.remove(column);
                    i--;
                    continue;
                    //部门查询编码
                case "ownerDeptQueryCode":
                    columns.remove(column);
                    i--;
                    continue;
                default:
            }
            headers.add(column.getName());
        }
        return headers;
    }

    /**
     * 获取列表导出数据的表头信息
     *
     * @param columns 展示字段
     * @return List
     */
    protected List<BizQueryColumnModel> getHeaderColumns(List<BizQueryColumnModel> columns) {
        List<BizQueryColumnModel> headerColumns = new ArrayList<>();
        for (int i = 0; i < columns.size(); i++) {
            BizQueryColumnModel column = columns.get(i);
            //附件、图片、地址、地图定位：不支持导入，导入模板中过滤掉该字段
            if (BizPropertyType.ATTACHMENT.equals(column.getPropertyType())
                    || BizPropertyType.COMMENT.equals(column.getPropertyType())
                    || BizPropertyType.ADDRESS.equals(column.getPropertyType())
            ) {
                columns.remove(column);
                //不减1会跳过下一个
                i--;
                continue;
            }
            //导入模板过滤掉系统字段，例外（数据标题、单据号作为覆盖导入查询条件，拥有者、拥有者部门产品要求可修改）2019年8月21日15:12:21
            String propertyCode = column.getPropertyCode();
            switch (propertyCode) {
                //业务对象ID
                case "id":
                    columns.remove(column);
                    i--;
                    continue;
                    //创建人
                case "creater":
                    columns.remove(column);
                    i--;
                    continue;
                    //创建人部门
                case "createdDeptId":
                    columns.remove(column);
                    i--;
                    continue;
                    //拥有者部门
                case "ownerDeptId":
                    columns.remove(column);
                    i--;
                    continue;
                    //创建时间
                case "createdTime":
                    columns.remove(column);
                    i--;
                    continue;
                    //修改人
                case "modifier":
                    columns.remove(column);
                    i--;
                    continue;
                    //修改时间
                case "modifiedTime":
                    columns.remove(column);
                    i--;
                    continue;
                    //流程实例ID
                case "workflowInstanceId":
                    columns.remove(column);
                    i--;
                    continue;
                    //单据状态
                case "sequenceStatus":
                    columns.remove(column);
                    i--;
                    continue;
                    //部门查询编码
                case "ownerDeptQueryCode":
                    columns.remove(column);
                    i--;
                    continue;
                default:
            }
            headerColumns.add(column);
        }
        return headerColumns;
    }

    /**
     * 子表导入
     *
     * @param childData
     * @return
     */
    protected FileOperationResult importChildDatas(ChildDataOperationVO childData) {
        FileOperationResult result = new FileOperationResult();
        String fileName = childData.getFileName();
        //原有获取文件格式逻辑在文件名带有点号(例如2.3.xls)时校验错误
        String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);
        boolean equals = Objects.equals("xlsx", fileExtension);
        boolean equals1 = Objects.equals("xls", fileExtension);
        if (!(equals || equals1)) {
            result.setErrorType(2);
            result.setOperationResult(true);
            return result;
        }
        Map<String, List<String>> childHeaders = getChildHeaders(childData, false);
        List<String> headers = childHeaders.get("headers");
        List<String> codes = childHeaders.get("codes");

        List<Map<String, Object>> dataMaps = FileOperateHelper.getImportDatas(fileName, headers, codes);
        if (CollectionUtils.isEmpty(dataMaps)) {
            result.setOperationResult(true);
            result.setSuccessCount(0);
            result.setErrorCount(0);
            result.setErrorType(7);
            return result;
        }
        if (dataMaps.size() == 1 && dataMaps.get(0).get("success") != null && dataMaps.get(0).get("success").equals(false)) {
            result.setOperationResult(true);
            result.setErrorType(Integer.valueOf(dataMaps.get(0).get("type").toString()));
            return result;
        }
        BizSchemaModel bizSchemaModel = getAppManagementFacade().getBizSchemaBySchemaCode(childData.getSchemaCode(), true);
        List<BizPropertyModel> properties = bizSchemaModel.getProperties().stream().filter(t -> t.getCode().equals(childData.getSubSchemaCode())).collect(Collectors.toList()).get(0).getSubSchema().getProperties();
        List<BizPropertyType> propertyTypes = new ArrayList<>();
        for (String code : codes) {
            propertyTypes.add(properties.stream().filter(t -> t.getCode().equals(code)).collect(Collectors.toList()).get(0).getPropertyType());
        }
        result = disposeData(getUserId(), childData.getSchemaCode(), dataMaps, propertyTypes, headers, properties, childHeaders, null, null, childData.getSchemaCode());
        return result;
    }

    /**
     * 获取子表导出模板头信息
     *
     * @param childDataVO
     * @return
     */
    public Map<String, List<String>> getChildHeaders(ChildDataOperationVO childDataVO, Boolean isExportData) {
        List<String> headers = new ArrayList<>();
        List<String> codes = new ArrayList<>();
        List<String> editCodes = new ArrayList<>();
        Map<String, List<String>> map = new HashMap<>();
        WorkflowTemplateModel workflowTemplate = null;
        String subSchemaCode = childDataVO.getSubSchemaCode();
        List<String> strings = Splitter.on(".").splitToList(subSchemaCode);
        String code = strings.get(strings.size() - 1);
        BizFormModel bizForm = getAppManagementFacade().getBizForm(childDataVO.getSchemaCode(), childDataVO.getFormCode());
        List<BizPropertyModel> propertyModels = getAppManagementFacade().getBizSchemaBySchemaCode(childDataVO.getSchemaCode(), true).getProperties().stream().filter(t -> t.getCode().equals(code)).collect(Collectors.toList());
        Map<String, List<BizPropertyModel>> propertyMap = propertyModels.get(0).getSubSchema().getProperties().stream().collect(Collectors.groupingBy(BizPropertyModel::getCode));
        //需要忽略的数据项
        List<BizPropertyModel> ignoreProperties = null;
        if (isExportData) {
            ignoreProperties = propertyModels.get(0).getSubSchema().getProperties().stream().filter(t -> t.getPropertyType().equals(BizPropertyType.ATTACHMENT)).collect(Collectors.toList());
        } else {
            ignoreProperties = propertyModels.get(0).getSubSchema().getProperties().stream().filter(t -> t.getPropertyType().equals(BizPropertyType.ATTACHMENT) || t.getPropertyType().equals(BizPropertyType.ADDRESS)).collect(Collectors.toList());
        }
        List<String> ignoreCodes = null;
        if (CollectionUtils.isNotEmpty(ignoreProperties)) {
            ignoreCodes = ignoreProperties.stream().map(BizPropertyModel::getCode).collect(Collectors.toList());
        }
        List<PropertyPermission> permissions = null;
        Activity activity = null;
        boolean isOperationForm = false;
        if (StringUtils.isNotEmpty(childDataVO.getStartWorkflowCode())) {
            log.debug("发起流程导出模板");
            workflowTemplate = getAppManagementFacade().getPublishedWorkflowTemplate(childDataVO.getStartWorkflowCode());
            activity = workflowTemplate.getOriginateActivity();
        }
        if (StringUtils.isNotEmpty(childDataVO.getWorkitemId())) {
            log.debug("流程导出模板");
            WorkItemModel workItem_tmp = getWorkflowInstanceFacade().getWorkItem(childDataVO.getWorkitemId());
            if (workItem_tmp == null) {
                workItem_tmp = getWorkflowInstanceFacade().getFinishedWorkItem(childDataVO.getWorkitemId());
            }
            if (workItem_tmp == null) {
                workItem_tmp = getWorkflowInstanceFacade().getCirculateItem(childDataVO.getWorkitemId());
            }
            if (workItem_tmp == null) {
                workItem_tmp = getWorkflowInstanceFacade().getFinsishedCirculateItem(childDataVO.getWorkitemId());
            }
            WorkItemModel workItem = workItem_tmp;
            WorkflowInstanceModel workflowInstance = getWorkflowInstanceFacade().getWorkflowInstance(workItem.getInstanceId());
            workflowTemplate = getAppManagementFacade().getPublishedWorkflowTemplate(workflowInstance.getWorkflowCode(), workflowInstance.getWorkflowVersion());
            activity = workflowTemplate.getActivities().stream().filter(t -> t.getActivityCode().equals(workItem.getActivityCode())).collect(Collectors.toList()).get(0);
        }
        if (workflowTemplate != null && activity != null && activity instanceof ParticipantActivity) {
            permissions = ((ParticipantActivity) activity).getPropertyPermissions().stream().filter(t -> t.isVisible() && t.getPropertyCode().equals(childDataVO.getSubSchemaCode())).collect(Collectors.toList());
        }
        if (activity == null) {
            isOperationForm = true;
        }
        String publishedAttributesJson = bizForm.getPublishedAttributesJson();
        //解析表单设置的权限

        List<Map> childColumns = getChildColumns(publishedAttributesJson, childDataVO.getSubSchemaCode());
        if (CollectionUtil.isNotEmpty(childColumns)) {
            List<Map> textColums = childColumns.stream().filter(t -> {
                String[] keys = {"1", "2"};
                if (Arrays.asList(keys).contains(t.get("type").toString())) {
                    return true;
                }

                return false;
            }).collect(Collectors.toList());
            parseJsonAttribute(map, textColums, "maxLength", "Text");

            List<Map> danxunColumns = childColumns.stream().filter(t -> {
                String[] keys = {"5"};
                if (Arrays.asList(keys).contains(t.get("type").toString())) {
                    return true;
                }
                return false;
            }).collect(Collectors.toList());

            parseJsonAttribute(map, danxunColumns, "options", "Radio");

            List<Map> duoxuanColums = childColumns.stream().filter(t -> {
                String[] keys = {"6"};
                if (Arrays.asList(keys).contains(t.get("type").toString())) {
                    return true;
                }
                return false;
            }).collect(Collectors.toList());
            parseJsonAttribute(map, duoxuanColums, "options", "Checkbox");

            List<Map> xialaColums = childColumns.stream().filter(t -> {
                String[] keys = {"7"};
                if (Arrays.asList(keys).contains(t.get("type").toString())) {
                    return true;
                }
                return false;
            }).collect(Collectors.toList());
            //parseJsonAttribute(map, xialaColums, "options", "Dropdown");
            parseJsonAttribute_dropdown(map, xialaColums, "options", "Dropdown");

            childColumns = childColumns.stream().filter(t -> {
                Object object = t.get("options");
                if (object != null && object instanceof JSONObject) {
                    return (Boolean) ((JSONObject) object).get("visible");
                }
                return false;
            }).collect(Collectors.toList());
        }

        if (childDataVO.getPermiss() != null) {
            permissions = convert2Permissions(childDataVO.getPermiss());
        }
        if (!isOperationForm) {
            if (CollectionUtils.isEmpty(permissions) || CollectionUtils.isEmpty(childColumns)) {
                throw new PortalException(5000L, "无数据项可导出");
            }
            List<String> collect = permissions.get(0).getSubPropertyPermissions().stream().filter(t -> t.isVisible()).map(PropertyPermission::getPropertyCode).collect(Collectors.toList());
            if (CollectionUtils.isNotEmpty(ignoreCodes)) {
                collect.removeAll(ignoreCodes);
            }
            List<String> editCollect = permissions.get(0).getSubPropertyPermissions().stream().filter(t -> t.isEditable()).map(PropertyPermission::getPropertyCode).collect(Collectors.toList());
            for (Map childColumn : childColumns) {
                if (collect.contains(childColumn.get("key").toString())) {
                    headers.add(propertyMap.get(childColumn.get("key").toString()).get(0).getName());
                    codes.add(childColumn.get("key").toString());
                }
                if (editCollect.contains(childColumn.get("key").toString())) {
                    editCodes.add(childColumn.get("key").toString());
                }

            }
            map.put("headers", headers);
            map.put("codes", codes);
            map.put("editCodes", editCodes);
            return map;
        }
        //获取后台配置数据项权限
        List<BizPermGroupModel> bizPermGroups = getAppManagementFacade().getBizPermGroupsByUserIdAndSchemaCode(getUserId(), childDataVO.getSchemaCode());
        if (CollectionUtils.isEmpty(bizPermGroups) && CollectionUtil.isNotEmpty(childColumns)) {
            for (Map childColumn : childColumns) {
                if (CollectionUtils.isNotEmpty(ignoreCodes) && ignoreCodes.contains(childColumn.get("key").toString())) {
                    continue;
                }
                headers.add(propertyMap.get(childColumn.get("key").toString()).get(0).getName());
                codes.add(childColumn.get("key").toString());
            }
            map.put("headers", headers);
            map.put("codes", codes);
            if (StringUtils.isEmpty(childDataVO.getObjectId()) || SequenceStatus.DRAFT.equals(childDataVO.getSequenceStatus()) || childDataVO.getSequenceStatus() == null) {
                map.put("editCodes", codes);
            }
            return map;
        }
        if (CollectionUtil.isNotEmpty(bizPermGroups)) {
            List<BizPermPropertyModel> permPropertyModels = bizPermGroups.stream().map(BizPermGroupModel::getPermProperties).reduce(new ArrayList<>(), (all, item) -> {
                all.addAll(item);
                return all;
            });
            List<String> propertyPermCodes = null;
            List<String> editPropertyPermCodes = null;
            //获取所有已配置的数据项
            List<String> permCodes = null;
            if (StringUtils.isEmpty(childDataVO.getObjectId()) || childDataVO.getSequenceStatus() == null) {
                //新增权限
                permCodes = permPropertyModels.stream().filter(t -> t.getBizPermType().equals(BizPermType.ADD)).map(BizPermPropertyModel::getPropertyCode).collect(Collectors.toList());
                propertyPermCodes = permPropertyModels.stream().filter(t -> t.getVisible() && t.getBizPermType().equals(BizPermType.ADD) && t.getVisible()).map(BizPermPropertyModel::getPropertyCode).collect(Collectors.toList());
                editPropertyPermCodes = permPropertyModels.stream().filter(t -> t.getVisible() && t.getBizPermType().equals(BizPermType.ADD) && t.getVisible() && t.getWriteAble()).map(BizPermPropertyModel::getPropertyCode).collect(Collectors.toList());
            } else {
                //编辑权限
                permCodes = permPropertyModels.stream().filter(t -> t.getBizPermType().equals(BizPermType.EDIT)).map(BizPermPropertyModel::getPropertyCode).collect(Collectors.toList());
                propertyPermCodes = permPropertyModels.stream().filter(t -> t.getVisible() && t.getBizPermType().equals(BizPermType.EDIT) && t.getVisible()).map(BizPermPropertyModel::getPropertyCode).collect(Collectors.toList());
                editPropertyPermCodes = permPropertyModels.stream().filter(t -> t.getVisible() && t.getBizPermType().equals(BizPermType.EDIT) && t.getVisible() && t.getWriteAble()).map(BizPermPropertyModel::getPropertyCode).collect(Collectors.toList());
            }
            for (Map childColumn : childColumns) {
                if (CollectionUtils.isNotEmpty(ignoreCodes) && ignoreCodes.contains(childColumn.get("key").toString())) {
                    continue;
                }
                if (!permCodes.contains(childColumn.get("key").toString())) {
                    headers.add(propertyMap.get(childColumn.get("key").toString()).get(0).getName());
                    codes.add(childColumn.get("key").toString());
                    editCodes.add(childColumn.get("key").toString());
                }
                if (propertyPermCodes.contains(childColumn.get("key").toString())) {
                    headers.add(propertyMap.get(childColumn.get("key").toString()).get(0).getName());
                    codes.add(childColumn.get("key").toString());
                }
                if (editPropertyPermCodes.contains(childColumn.get("key").toString())) {
                    editCodes.add(childColumn.get("key").toString());
                }
            }
        }

        map.put("headers", headers);
        map.put("codes", codes);
        map.put("editCodes", editCodes);
        return map;
    }

    private List<PropertyPermission> convert2Permissions(DataPermissionVO permiss) {
        List<PropertyPermission> permissions = Lists.newArrayList();
        PropertyPermission propertyPermission = new PropertyPermission();
        propertyPermission.setPropertyCode(permiss.getPropertyCode());
        propertyPermission.setEditable(permiss.getE());
        propertyPermission.setVisible(permiss.getV());
        propertyPermission.setRequired(permiss.getR());
        List<PropertyPermission> subPropertyPermissions = Lists.newArrayList();
        List<DataPermissionVO> subDataPermission = permiss.getSubDataPermission();
        for (DataPermissionVO p : subDataPermission) {
            PropertyPermission tempPermission = new PropertyPermission();
            tempPermission.setPropertyCode(p.getPropertyCode());
            tempPermission.setEditable(p.getE());
            tempPermission.setVisible(p.getV());
            tempPermission.setRequired(p.getR());
            subPropertyPermissions.add(tempPermission);
        }
        propertyPermission.setSubPropertyPermissions(subPropertyPermissions);
        permissions.add(propertyPermission);
        return permissions;
    }

    private void parseJsonAttribute(Map<String, List<String>> map, List<Map> columns, String attribute, String key) {
        if (CollectionUtils.isEmpty(columns)) {
            return;
        }
        List<String> list = new ArrayList<>();
        for (Map column : columns) {
            Object object = column.get("options");
            if (object != null && object instanceof JSONObject) {
                Map<String, String> mapTem = new HashMap<>();
                mapTem.put(column.get("key").toString(), ((JSONObject) object).get(attribute).toString());
                list.add(JSON.toJSONString(mapTem));
            }
        }
        if (CollectionUtils.isNotEmpty(list)) {
            map.put(key, list);
        }
    }


    private void parseJsonAttribute_dropdown(Map<String, List<String>> map, List<Map> columns, String attribute, String key) {
        if (CollectionUtils.isEmpty(columns)) {
            return;
        }
        List<String> list = new ArrayList<>();
        for (Map column : columns) {
            Object object = column.get("options");
            if (object != null && object instanceof JSONObject) {
                Map<String, String> mapTem = new HashMap<>();
                mapTem.put(column.get("key").toString(), ((JSONObject) object).get(attribute).toString());
                mapTem.put("multi", ((JSONObject) object).get("multi").toString());

                Map<String, Map<String, String>> map2 = new HashMap<>();
                map2.put(column.get("key").toString(), mapTem);
                list.add(JSON.toJSONString(map2));
            }
        }
        if (CollectionUtils.isNotEmpty(list)) {
            map.put(key, list);
        }
    }

    /**
     * 获取需要导出的数据
     *
     * @param childData
     * @param codes
     * @return
     */
    public List<Map<String, Object>> getChildDatas(ChildDataOperationVO childData, List<String> codes) {
        BizObjectCreatedModel bizObject = getBizObjectFacade().getBizObject(getUserId(), childData.getSchemaCode(), childData.getObjectId());
        Object object = bizObject.getData().get(childData.getSubSchemaCode());
        if (object == null) {
            return null;
        }
        List<Map<String, Object>> maps = new ArrayList<>();
        if (object instanceof List) {
            maps = (List<Map<String, Object>>) object;
        }
        parseChildData(maps, childData, codes);
        List<Map<String, Object>> datas = new ArrayList<>();
        if (CollectionUtils.isNotEmpty(childData.getObjectIds())) {
            //选择性导出
            for (Map<String, Object> map : maps) {
                if (childData.getObjectIds().contains(map.get(DefaultPropertyType.ID.getCode()))) {
                    Map<String, Object> mapTem = new LinkedHashMap();
                    for (String code : codes) {
                        mapTem.put(code, map.get(code));
                    }
                    datas.add(mapTem);
                }
            }
            return datas;
        }
        for (Map<String, Object> map : maps) {
            Map<String, Object> mapTem = new LinkedHashMap();
            for (String code : codes) {
                mapTem.put(code, map.get(code));
            }
            datas.add(mapTem);
        }
        return datas;
    }

    /**
     * 处理子表导出信息
     *
     * @param maps
     * @param childData
     * @param codes
     */
    private void parseChildData(List<Map<String, Object>> maps, ChildDataOperationVO childData, List<String> codes) {
        BizSchemaModel bizSchemaModel = getAppManagementFacade().getBizSchemaBySchemaCode(childData.getSchemaCode(), true);
        List<BizPropertyModel> bizProperties = bizSchemaModel.getProperties().stream().filter(t -> t.getCode().equals(childData.getSubSchemaCode())).collect(Collectors.toList()).get(0).getSubSchema().getProperties().stream().filter(t -> codes.contains(t.getCode())).collect(Collectors.toList());
        Map<String, List<BizPropertyModel>> propertyMap = bizProperties.stream().collect(Collectors.groupingBy(BizPropertyModel::getCode));
        List<BizPropertyModel> collect = bizProperties.stream().filter(t -> t.getPropertyType().equals(BizPropertyType.NUMERICAL)).collect(Collectors.toList());
        List<BizPropertyModel> collectAddress = bizProperties.stream().filter(t -> t.getPropertyType().equals(BizPropertyType.ADDRESS)).collect(Collectors.toList());
        Map<String, String> mapTemplate = new HashMap<>();
        Map<String, String> mapTemplateAddress = new HashMap<>();
        if (CollectionUtils.isNotEmpty(collect) || CollectionUtils.isNotEmpty(collectAddress)) {
            BizFormModel sheetModel = getAppManagementFacade().getBizForm(childData.getSchemaCode(), childData.getFormCode());
            List<Map> childColumns = getChildColumns(sheetModel.getPublishedAttributesJson(), childData.getSubSchemaCode());
            for (BizPropertyModel bizPropertyModel : collect) {
                for (Map childColumn : childColumns) {
                    if (childColumn.get("key").toString().equals(bizPropertyModel.getCode())) {
                        Map map2 = JSON.parseObject(childColumn.get("options").toString(), Map.class);
                        mapTemplate.put(bizPropertyModel.getCode(), map2.get("format").toString());
                    }
                }
            }
            for (BizPropertyModel bizPropertyModel : collectAddress) {
                for (Map childColumn : childColumns) {
                    if (childColumn.get("key").toString().equals(bizPropertyModel.getCode())) {
                        mapTemplateAddress.put(bizPropertyModel.getCode(), childColumn.get("type").toString());
                    }
                }
            }
        }
        for (Map<String, Object> map : maps) {
            for (String code : codes) {
                if (map.get(code) == null) {
                    continue;
                }
                BizPropertyModel bizPropertyModel = propertyMap.get(code).get(0);
                BizPropertyType bizPropertyType = bizPropertyModel.getPropertyType();
                if (bizPropertyModel.getPropertyType().equals(BizPropertyType.ADDRESS)) {
                    if (map.get(code) != null) {
                        String json = map.get(code).toString();
                        if ("{}".equals(json)) {
                            json = null;
                            map.put(code, null);
                        }
                        Map mapTem = JSONObject.parseObject(json, Map.class);
                        if (mapTem == null) {
                            continue;
                        }
                        String name = "";
                        if (mapTem.get("provinceName") != null) {
                            name = name + mapTem.get("provinceName");
                        }
                        if (mapTem.get("cityName") != null) {
                            name = name + mapTem.get("cityName");
                        }
                        if (mapTem.get("districtName") != null) {
                            name = name + mapTem.get("districtName");
                        }
                        if (mapTem.get("address") != null) {
                            name = name + mapTem.get("address");
                        }

                        map.put(code, name);
                    }
                }
                if (bizPropertyModel.getPropertyType().equals(BizPropertyType.WORK_SHEET)) {
                    if (map.get(code) != null) {
                        Map mapInfo = (Map) map.get(code);
                        map.put(code, StringUtils.isBlank(bizPropertyModel.getRelativePropertyCode()) ? null : mapInfo.get(bizPropertyModel.getRelativePropertyCode()));
                    }
                }
                if (bizPropertyModel.getPropertyType().equals(BizPropertyType.MULT_WORK_SHEET)) {
                    if (map.get(code) != null) {
                        Map mapInfo = (Map) map.get(code);
                        map.put(code, mapInfo.get(bizPropertyModel.getRelativePropertyCode()) == null ? null : mapInfo.get(bizPropertyModel.getRelativePropertyCode()));
                    }
                }
                if (bizPropertyModel.getPropertyType().equals(BizPropertyType.NUMERICAL)) {
                    if (map.get(code) == null) {
                        continue;
                    }
                    if (map.get(code) instanceof BigDecimal) {
                        if (((BigDecimal) map.get(code)).compareTo(BigDecimal.ZERO) == 0) {
                            map.put(code, 0);
                            continue;
                        }
                    }

                    fmtNum(mapTemplate, map, code);
                }
                if (bizPropertyModel.getPropertyType().equals(BizPropertyType.SELECTION)) {
                    List<SelectionValue> selectionValues = (List<SelectionValue>) map.get(code);
                    map.put(code, getUserAndDepartNames(selectionValues));
                }
                if (bizPropertyModel.getPropertyType().equals(BizPropertyType.LOGICAL)) {
                    map.put(code, disposeLogic(map.get(code).toString()));
                }

                if (bizPropertyType == BizPropertyType.ATTACHMENT) {
                    Object object = map.get(code);
                    if (object != null) {
                        List<Map> list = (List<Map>) object;
                        for (Map attachmentMap : list) {
                            Object refId = attachmentMap.get("refId");
                            attachmentMap.put("attachmentUrl", getAttachmentDownloadUrl((String) refId));
                        }
                    }
                }

            }
        }
    }

    protected String getAttachmentDownloadUrl(String refId) {
        String downloadUrl;
        String prefix = servletContextPath.endsWith("/") ? "" : "/";
        downloadUrl = serverDomain + servletContextPath + prefix + "api/fileServer/attachment?refId=" + refId;
        return downloadUrl;
    }

    protected void fmtNum(Map<String, String> mapTemplate, Map<String, Object> map, String code) {
        DecimalFormat df;

        Object codeObj = map.get(code);
        boolean isNull = Objects.isNull(codeObj) || StringUtils.isBlank(String.valueOf(codeObj));
        Object value = isNull ? 0 : codeObj;
        String obj = String.valueOf(value).replaceAll(",", "");

        switch (mapTemplate.get(code)) {
            case "integer":
                df = new DecimalFormat("###,##0");
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "tenths":
                df = new DecimalFormat("###,##0.0");
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "percentile":
                df = new DecimalFormat("###,##0.00");
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "Millimeter":
                df = new DecimalFormat("###,##0.000");
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "tenThousand":
                df = new DecimalFormat("###,##0.0000");
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "hundredThousand":
                df = new DecimalFormat("###,##0.00000");
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "millionDecimals":
                df = new DecimalFormat("###,##0.000000");
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "tenMillionDecimals":
                df = new DecimalFormat("###,##0.0000000");
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "billionDecimals":
                df = new DecimalFormat("###,##0.00000000");
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "ratio":
                map.put(code, fmtPercentData("#%", obj));
                break;
            case "ratio.tenths":
                map.put(code, fmtPercentData("#0.0%", obj));
                break;
            case "ratio.percentile":
                map.put(code, fmtPercentData("#0.00%", obj));
                break;
            case "ratio.Millimeter":
                map.put(code, fmtPercentData("###,##0.000%", obj));
                break;
            case "ratio.tenThousand":
                map.put(code, fmtPercentData("###,##0.0000%", obj));
                break;
            case "ratio.hundredThousand":
                map.put(code, fmtPercentData("###,##0.00000%", obj));
                break;
            case "ratio.millionDecimals":
                map.put(code, fmtPercentData("###,##0.000000%", obj));
                break;
            case "ratio.tenMillionDecimals":
                map.put(code, fmtPercentData("###,##0.0000000%", obj));
                break;
            case "ratio.billionDecimals":
                map.put(code, fmtPercentData("###,##0.00000000%", obj));
                break;
            case "RMB.percentile":
                df = new DecimalFormat("¥#,##0.00");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "RMB.Millimeter":
                df = new DecimalFormat("¥#,##0.000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "RMB.tenThousand":
                df = new DecimalFormat("¥#,##0.0000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "RMB.hundredThousand":
                df = new DecimalFormat("¥#,##0.00000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "RMB.millionDecimals":
                df = new DecimalFormat("¥#,##0.000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "RMB.tenMillionDecimals":
                df = new DecimalFormat("¥#,##0.0000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "RMB.billionDecimals":
                df = new DecimalFormat("¥#,##0.00000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "dollar.percentile":
                df = new DecimalFormat("$#,##0.00");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "dollar.Millimeter":
                df = new DecimalFormat("$#,##0.000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "dollar.tenThousand":
                df = new DecimalFormat("$#,##0.0000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "dollar.hundredThousand":
                df = new DecimalFormat("$#,##0.00000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "dollar.millionDecimals":
                df = new DecimalFormat("$#,##0.000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "dollar.tenMillionDecimals":
                df = new DecimalFormat("$#,##0.0000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "dollar.billionDecimals":
                df = new DecimalFormat("$#,##0.00000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "euro.percentile":
                df = new DecimalFormat("€#,##0.00");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "euro.Millimeter":
                df = new DecimalFormat("€#,##0.000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "euro.tenThousand":
                df = new DecimalFormat("€#,##0.0000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "euro.hundredThousand":
                df = new DecimalFormat("€#,##0.00000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "euro.millionDecimals":
                df = new DecimalFormat("€#,##0.000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "euro.tenMillionDecimals":
                df = new DecimalFormat("€#,##0.0000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "euro.billionDecimals":
                df = new DecimalFormat("€#,##0.00000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "HK.percentile":
                df = new DecimalFormat("HK$#,##0.00");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "HK.Millimeter":
                df = new DecimalFormat("HK$#,##0.000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "HK.tenThousand":
                df = new DecimalFormat("HK$#,##0.0000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "HK.hundredThousand":
                df = new DecimalFormat("HK$#,##0.00000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "HK.millionDecimals":
                df = new DecimalFormat("HK$#,##0.000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "HK.tenMillionDecimals":
                df = new DecimalFormat("HK$#,##0.0000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            case "HK.billionDecimals":
                df = new DecimalFormat("HK$#,##0.00000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                break;
            default:
                break;
        }
    }

    protected void fmtNumByColumnModel(Map<String, String> mapTemplate, Map<String, Object> map, String code, BizQueryColumnModel columnModel) {
        log.debug("format=======");
        DecimalFormat df;
        Object codeObj = map.get(code);
        boolean isNull = Objects.isNull(codeObj) || StringUtils.isBlank(String.valueOf(codeObj));
        Object value = isNull ? 0 : codeObj;
        String obj = String.valueOf(value).replaceAll(",", "");

        switch (mapTemplate.get(code)) {
            case "integer":
                df = new DecimalFormat("###,##0");
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(1);
                break;
            case "tenths":
                df = new DecimalFormat("###,##0.0");
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(2);
                break;
            case "percentile":
                df = new DecimalFormat("###,##0.00");
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(3);
                break;
            case "Millimeter":
                df = new DecimalFormat("###,##0.000");
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(11);
                break;
            case "tenThousand":
                df = new DecimalFormat("###,##0.0000");
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(12);
                break;
            case "hundredThousand":
                df = new DecimalFormat("###,##0.00000");
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(23);
                break;
            case "millionDecimals":
                df = new DecimalFormat("###,##0.000000");
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(24);
                break;
            case "tenMillionDecimals":
                df = new DecimalFormat("###,##0.0000000");
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(25);
                break;
            case "billionDecimals":
                df = new DecimalFormat("###,##0.00000000");
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(26);
                break;
            case "ratio":
                map.put(code, fmtPercentData("#%", obj));
                columnModel.setDisplayFormat(4);
                break;
            case "ratio.tenths":
                map.put(code, fmtPercentData("#0.0%", obj));
                columnModel.setDisplayFormat(5);
                break;
            case "ratio.percentile":
                map.put(code, fmtPercentData("#0.00%", obj));
                columnModel.setDisplayFormat(6);
                break;
            case "ratio.Millimeter":
                map.put(code, fmtPercentData("###,##0.000%", obj));
                columnModel.setDisplayFormat(13);
                break;
            case "ratio.tenThousand":
                map.put(code, fmtPercentData("###,##0.0000%", obj));
                columnModel.setDisplayFormat(14);
                break;
            case "ratio.hundredThousand":
                map.put(code, fmtPercentData("###,##0.00000%", obj));
                columnModel.setDisplayFormat(27);
                break;
            case "ratio.millionDecimals":
                map.put(code, fmtPercentData("###,##0.000000%", obj));
                columnModel.setDisplayFormat(28);
                break;
            case "ratio.tenMillionDecimals":
                map.put(code, fmtPercentData("###,##0.0000000%", obj));
                columnModel.setDisplayFormat(29);
                break;
            case "ratio.billionDecimals":
                map.put(code, fmtPercentData("###,##0.00000000%", obj));
                columnModel.setDisplayFormat(30);
                break;
            case "RMB.percentile":
                df = new DecimalFormat("¥#,##0.00");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(7);
                break;
            case "RMB.Millimeter":
                df = new DecimalFormat("¥#,##0.000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(15);
                break;
            case "RMB.tenThousand":
                df = new DecimalFormat("¥#,##0.0000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(16);
                break;
            case "RMB.hundredThousand":
                df = new DecimalFormat("¥#,##0.00000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(31);
                break;
            case "RMB.millionDecimals":
                df = new DecimalFormat("¥#,##0.000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(32);
                break;
            case "RMB.tenMillionDecimals":
                df = new DecimalFormat("¥#,##0.0000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(33);
                break;
            case "RMB.billionDecimals":
                df = new DecimalFormat("¥#,##0.00000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(34);
                break;
            case "dollar.percentile":
                df = new DecimalFormat("$#,##0.00");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(8);
                break;
            case "dollar.Millimeter":
                df = new DecimalFormat("$#,##0.000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(17);
                break;
            case "dollar.tenThousand":
                df = new DecimalFormat("$#,##0.0000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(18);
                break;
            case "dollar.hundredThousand":
                df = new DecimalFormat("$#,##0.00000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(35);
                break;
            case "dollar.millionDecimals":
                df = new DecimalFormat("$#,##0.000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(36);
                break;
            case "dollar.tenMillionDecimals":
                df = new DecimalFormat("$#,##0.0000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(37);
                break;
            case "dollar.billionDecimals":
                df = new DecimalFormat("$#,##0.00000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(38);
                break;
            case "euro.percentile":
                df = new DecimalFormat("€#,##0.00");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(9);
                break;
            case "euro.Millimeter":
                df = new DecimalFormat("€#,##0.000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(19);
                break;
            case "euro.tenThousand":
                df = new DecimalFormat("€#,##0.0000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(20);
                break;
            case "euro.hundredThousand":
                df = new DecimalFormat("€#,##0.00000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(39);
                break;
            case "euro.millionDecimals":
                df = new DecimalFormat("€#,##0.000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(40);
                break;
            case "euro.tenMillionDecimals":
                df = new DecimalFormat("€#,##0.0000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(41);
                break;
            case "euro.billionDecimals":
                df = new DecimalFormat("€#,##0.00000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(42);
                break;
            case "HK.percentile":
                df = new DecimalFormat("HK$#,##0.00");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(10);
                break;
            case "HK.Millimeter":
                df = new DecimalFormat("HK$#,##0.000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(21);
                break;
            case "HK.tenThousand":
                df = new DecimalFormat("HK$#,##0.0000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(22);
                break;
            case "HK.hundredThousand":
                df = new DecimalFormat("HK$#,##0.00000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(43);
                break;
            case "HK.millionDecimals":
                df = new DecimalFormat("HK$#,##0.000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(44);
                break;
            case "HK.tenMillionDecimals":
                df = new DecimalFormat("HK$#,##0.0000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(45);
                break;
            case "HK.billionDecimals":
                df = new DecimalFormat("HK$#,##0.00000000");
                df.setRoundingMode(RoundingMode.DOWN);
                map.put(code, df.format(new BigDecimal(obj)));
                columnModel.setDisplayFormat(46);
                break;
            default:
                break;
        }
    }


    protected String fmtPercentData(String pattern, Object num) {
        DecimalFormat df = new DecimalFormat(pattern);
        df.setRoundingMode(RoundingMode.DOWN);
        BigDecimal divPer = new BigDecimal(String.valueOf(num));
        BigDecimal divide = divPer.divide(BigDecimal.valueOf(100));
        return df.format(divide);
    }

    /**
     * 解析表单配置信息
     *
     * @param jsonString
     * @param subSchemaCode
     * @return
     */
    protected List<Map> getChildColumns(String jsonString, String subSchemaCode) {
        if (StringUtils.isEmpty(jsonString)) {
            return null;
        }
        Map map = JSON.parseObject(jsonString, Map.class);
        List<String> codes = Splitter.on(".").splitToList(subSchemaCode);
        int size = codes.size();
        Object result = null;
        result = parseChildHeaders(size, codes, map, result);

        if (null != result) {
            Object columns = ((JSONObject) result).get("columns");
            if (columns instanceof JSONArray) {
                return JSONObject.parseArray(JSON.toJSONString(columns), Map.class);
            } else if (columns instanceof List) {
                return (List) columns;
            }
        }

        return null;
    }

    private void getFormChildHeaders(Map map, String childCode, List<Object> childHeaders) {
        if (map == null) {
            return;
        }
        if (childHeaders.size() > 0) {
            return;
        }
        Object o = map.get(childCode);
        if (o != null) {
            childHeaders.add(o);
            return;
        }
        try {
            Collection<Map> values = (Collection<Map>) map.values();
            Collection<Map> childValues = values.stream().filter(e -> 500 == Integer.parseInt(((Map<String, Object>) e).get("type").toString())).collect(Collectors.toList());
            for (Map tabs : childValues) {
                Collection<Map> panels = (Collection<Map>) tabs.get("panels");
                for (Map panel : panels) {
                    Map controls = (Map) panel.get("controls");
                    getFormChildHeaders(controls, childCode, childHeaders);
                }
            }
        } catch (Exception e) {
            log.error("getFormChildHeaders error", e);
        }
    }

    private Object parseChildHeaders(int size, List<String> codes, Map map, Object result) {
        if (size == 1) {
            result = map.get(codes.get(0));
            if (result == null) {
                List<Object> childHeaders = Lists.newArrayList();
                getFormChildHeaders(map, codes.get(0), childHeaders);
                if (childHeaders.size() > 0) {
                    result = childHeaders.get(0);
                }
            }
            return result;
        } else {
            for (int i = 0; i < size; i++) {
                Object o = map.get(codes.get(i));
                Map<String, List<Map<String, Object>>> ret = (Map<String, List<Map<String, Object>>>) o;
                List<Map<String, Object>> mapList = ret.get("panels");
                for (Map<String, Object> re : mapList) {
                    if (MapUtils.isEmpty(re)) {
                        continue;
                    }
                    Object controls = re.get("controls");
                    if (Objects.isNull(controls)) {
                        continue;
                    }
                    Map<String, Object> rets = (Map<String, Object>) controls;
                    Object object = rets.get(codes.get(i + 1));
                    if (Objects.nonNull(object) && i + 1 == size - 1) {
                        result = object;
                        return result;
                    } else if (Objects.nonNull(object)) {
                        map = (Map) controls;
                        break;
                    }
                }
            }
        }
        return null;
    }

    /**
     * 解析获取到的excel数据
     *
     * @param schemaCode    模型编码
     * @param dataMaps      excel解析后的数据有序
     * @param propertyTypes 需要展示的数据项类型集合有序
     * @param headers       表头集合有序
     * @param properties    模型对应的数据项有序
     * @return FileOperationResult
     */
    private FileOperationResult disposeData(String userId, String schemaCode, List<Map<String, Object>> dataMaps, List<BizPropertyType> propertyTypes, List<String> headers, List<BizPropertyModel> properties, Map<String, List<String>> attrituteMaps, String queryField, List<BizQueryColumnModel> headerColumns, String queryCode) {
        mapFileOperateInfo.remove(userId);
        //错误信息
        List<Map<String, Object>> errorMaps = new ArrayList<>();
        //导入数据
        List<BizObjectModel> bizObjects = new ArrayList<>();

        //子表数据
        List<Map<String, Object>> childMaps = new ArrayList<>();

        //二次重试
        List<Map<String, Object>> secondList = Lists.newArrayList();

        List<String> editCodes = null;
        if (attrituteMaps != null) {
            editCodes = attrituteMaps.get("editCodes");
            if (CollectionUtils.isEmpty(editCodes)) {
                //防止没有可写项
                editCodes.add("id");
            }
        }
        //主表
        boolean isQueryData = true;
        //子表
        if (CollectionUtils.isNotEmpty(editCodes)) {
            isQueryData = false;
        }

        //传参参数过多问题
        Map<String, Object> paramMap = Maps.newHashMap();
        paramMap.put("userId", userId);
        paramMap.put("bizObjects", bizObjects);
        paramMap.put("editCodes", editCodes);
        paramMap.put("schemaCode", schemaCode);
        paramMap.put("propertyTypes", propertyTypes);
        paramMap.put("headers", headers);
        paramMap.put("queryField", queryField);
        paramMap.put("headerColumns", headerColumns);

        FileOperationResult operationResult = new FileOperationResult();
        operationResult.setDropdownMarkedCount(0);
        operationResult.setRadioMarkedCount(0);
        operationResult.setCheckboxMarkedCount(0);
        //校验
        checkDataItems(errorMaps, childMaps, dataMaps, properties, attrituteMaps, paramMap, secondList, queryCode, operationResult);
        int errorType = 0;
        boolean empty = CollectionUtils.isEmpty(secondList);
        boolean empty1 = CollectionUtils.isEmpty(errorMaps);
        boolean empty2 = CollectionUtils.isEmpty(bizObjects);
        boolean equals = (!empty1) && (empty2);
        boolean equals1 = (!empty1) && (!empty2);
        boolean equals2 = (empty) && (empty1) && (!empty2);
        boolean equals3 = !empty && empty1;
        if (equals3) {
            log.info("重试数据条数：retrySize={}", secondList.size());
            errorType = 8;
        } else if (equals) {
            log.info("失败数据条数：errorSize={}", errorMaps.size());
            errorType = 1;
        } else if (equals1) {
            log.info("数据条数：errorSize={},successSize={}", errorMaps.size(), bizObjects.size());
            errorType = 1;
        } else if (equals2) {
            log.info("成功数据条数：successSize={}", bizObjects.size());
            errorType = 0;
        }
        List<Map<String, Object>> list = CollectionUtils.isEmpty(secondList) ? new ArrayList<>() : secondList;
        operationResult.setSecondImportData(list);
        operationResult.setErrorType(errorType);
        operationResult.setSuccessCount(0);
        operationResult.setErrorCount(0);
        operationResult.setOperationResult(true);
        //批量更新
        if (CollectionUtils.isNotEmpty(errorMaps) && errorMaps.size() > 0) {
            //创建错误信息excel
            if (CollectionUtils.isNotEmpty(headers)) {
                headers.add("错误信息");
            }
            Boolean isChild = !isQueryData;
            String fileName = FileOperateHelper.createFiles(headers, errorMaps, isChild, headerColumns);
            operationResult.setErrorCount(errorMaps.size());
            operationResult.setFileName(fileName);
        }
        if (CollectionUtils.isNotEmpty(secondList)) {
            operationResult.setRetryCount(secondList.size());
            operationResult.setHeadColumns(headerColumns);
            operationResult.setSecondImportData(secondList);
            if (StringUtils.isNotEmpty(queryField)) {
                operationResult.setQueryField(queryField);
            }
        }
        if (isQueryData) {
            mapFileOperateInfo.put(userId, operationResult);
        }
        if (CollectionUtils.isNotEmpty(bizObjects)) {
            operationResult.setSuccessCount(bizObjects.size());
            getBizObjectFacade().addBizObjects(userId, bizObjects, queryField);
            log.info("==================批量更新========成功导入={}条", bizObjects.size());
        }
        if (CollectionUtils.isNotEmpty(childMaps)) {
            operationResult.setData(childMaps);
            operationResult.setSuccessCount(childMaps.size());
        }

        return operationResult;
    }

    //遍历excel表格传过来的值，校验对应数据项格式是否正确
    private void checkDataItems(List<Map<String, Object>> errorMaps, List<Map<String, Object>> childMaps,
                                List<Map<String, Object>> dataMaps, List<BizPropertyModel> properties,
                                Map<String, List<String>> attrituteMaps, Map<String, Object> paramMap,
                                List<Map<String, Object>> secondList, String queryCode, FileOperationResult operationResult) {

        //取出map中的参数
        String userId = String.valueOf(paramMap.get("userId"));
        List<BizObjectModel> bizObjects = (List<BizObjectModel>) paramMap.get("bizObjects");
        List<String> editCodes = (List<String>) paramMap.get("editCodes");
        String schemaCode = String.valueOf(paramMap.get("schemaCode"));
        List<BizPropertyType> propertyTypes = (List<BizPropertyType>) paramMap.get("propertyTypes");
        List<String> headers = (List<String>) paramMap.get("headers");
        String queryField = String.valueOf(paramMap.get("queryField"));
        List<BizQueryColumnModel> headerColumns = (List<BizQueryColumnModel>) paramMap.get("headerColumns");
        UserModel user = getOrganizationFacade().getUser(userId);
        String corpId = user.getCorpId();
        Boolean isBind = false;
        Map<String, List<BizPropertyModel>> childMap = Maps.newHashMap();
        //内存中预先存储子表及其数据项信息
        if (CollectionUtils.isNotEmpty(headerColumns)) {
            List<String> childProperties = headerColumns.stream().filter(bizQueryColumnModel -> Objects.equals(bizQueryColumnModel.getPropertyType(), BizPropertyType.CHILD_TABLE)).map(BizQueryColumnModel::getPropertyCode).collect(Collectors.toList());
            if (CollectionUtils.isNotEmpty(childProperties)) {
                for (String code : childProperties) {
                    BizSchemaModel bizSchemaBySchemaCode = getAppManagementFacade().getBizSchemaBySchemaCode(code);
                    List<BizPropertyModel> childPropertyList = bizSchemaBySchemaCode.getProperties();
                    childMap.put(code, childPropertyList);
                }
            }
        }
        BizFormModel bizFormModel = getBizFormModel(schemaCode, queryCode);

        String formCode = getAppManagementFacade().getBizForms(schemaCode).get(0).getCode();
        Map<String, Object> multWorkMap = initMultWorkSheet(properties, schemaCode, queryCode);
        List<String> defaultCodes = Arrays.stream(DefaultPropertyType.values()).map(DefaultPropertyType::getCode).collect(Collectors.toList());

        Map<String, String> textInfos = null;
        Map<String, String> radioInfos = null;
        Map<String, String> checkboxInfos = null;
        Map<String, String> dropdownInfos = null;
        Map<String, Map<String, String>> dropdownInfos2 = null;
        if (attrituteMaps != null) {
            editCodes = attrituteMaps.get("editCodes");
            if (CollectionUtils.isEmpty(editCodes)) {
                //防止没有可写项
                editCodes.add("id");
            }
            textInfos = parseAttribute(attrituteMaps, "Text");
            radioInfos = parseAttribute(attrituteMaps, "Radio");
            checkboxInfos = parseAttribute(attrituteMaps, "Checkbox");
            dropdownInfos = parseAttribute(attrituteMaps, "Dropdown");

            dropdownInfos2 = parseAttribute_dropdown(attrituteMaps, "Dropdown");
        }
        //主表
        boolean isQueryData = true;
        //子表
        if (CollectionUtils.isNotEmpty(editCodes)) {
            isQueryData = false;
        }
        DepartmentModel rootDept = getOrganizationFacade().getRootDepartmentByCorpId(corpId);
        RelatedCorpSettingModel relatedSettingModel = getSystemManagementFacade().getRelatedCorpSettingModelByCorpId(corpId);
        //组织机构是关联/主组织
        OrgType orgType = relatedSettingModel.getOrgType();

        //遍历
        for (Map<String, Object> map : dataMaps) {
            if (MapUtils.isEmpty(map)) {
                continue;
            }
            BizObjectModel bizObject = new BizObjectModel(schemaCode, null, false);

            boolean success = true;

            boolean ok = true;

            //错误的数据集合
            Map<String, Object> mapTemplates = new LinkedHashMap<>();

            //错误数据列
            List<ErrorValue> list = Lists.newLinkedList();

            Map<String, Object> workSheet = Maps.newLinkedHashMap();
            Map<String, Object> multWorkSheet = Maps.newLinkedHashMap();

            List<Object> errList = Lists.newArrayList();

            //先将每个列表对象的主表数据存入；
            if (CollectionUtils.isNotEmpty(headerColumns)) {
                List<String> collect = headerColumns.stream().filter(headerColumn -> (!Objects.equals(headerColumn.getPropertyType(), BizPropertyType.CHILD_TABLE))).map(BizQueryColumnModel::getPropertyCode).collect(Collectors.toList());
                if (CollectionUtils.isNotEmpty(collect)) {
                    for (String code : collect) {
                        mapTemplates.put(code, map.get(code));
                    }
                }
            } else {
                mapTemplates.putAll(map);
            }
            int i = 0;
            for (String key : map.keySet()) {
                String value = map.get(key) == null ? "" : String.valueOf(map.get(key));
                BizPropertyModel bizProperty = properties.stream().filter(t -> t.getCode().equals(key)).findAny().orElse(null);
                Boolean notEmpty = bizProperty.getPropertyEmpty();
                if (Objects.isNull(notEmpty)) {
                    notEmpty = true;
                }

                BizPropertyType bizPropertyType = bizProperty.getPropertyType();
                Object childValue = map.get(key);
                //todo: 数据项校验格式：
                //传参Map
                Map<String, Object> params = Maps.newHashMap();
                params.put("i", i);
                params.put("propertyTypes", propertyTypes);
                params.put("notEmpty", notEmpty);
                params.put("editCodes", editCodes);
                params.put("list", list);
                params.put("bizProperty", bizProperty);
                params.put("value", value);
                params.put("headers", headers);
                params.put("key", key);
                params.put("defaultCodes", defaultCodes);
                params.put("textInfos", textInfos);
                params.put("radioInfos", radioInfos);
                params.put("checkboxInfos", checkboxInfos);
                params.put("dropdownInfos", dropdownInfos);
                params.put("childValue", childValue);
                params.put("multWorkMap", multWorkMap);
                params.put("multWorkSheet", multWorkMap);

                switch (bizPropertyType) {
                    case WORK_SHEET:
                        checkWorkSheet(params, map, workSheet);
                        break;

                    case MULT_WORK_SHEET:
                        checkMultWorkSheet(params, map, multWorkSheet);
                        break;

                    case NUMERICAL:
                        checkNumerical(params, map);
                        break;

                    case DATE:
                        checkDate(params, map);
                        break;

                    case LOGICAL:
                        checkLogical(params, map);
                        break;

                    case LONG_TEXT:
                        checkLongText(params, map, textInfos);
                        break;

                    case SHORT_TEXT:
                        checkShortText(defaultCodes, textInfos, radioInfos, checkboxInfos, dropdownInfos,
                                params, map, operationResult, dropdownInfos2, bizFormModel);
                        break;

                    case SELECTION:
                        success = checkSelection(defaultCodes, params, map, success, corpId, userId, rootDept, orgType);
                        break;

                    case CHILD_TABLE:
                        ok = checkChild(params, map, key, mapTemplates, errList, ok,
                                childMap, corpId, rootDept, orgType, bizFormModel);
                        break;

                    default:
                }

                //todo:
                if (!isQueryData && !editCodes.contains(bizProperty.getCode())) {
                    map.put(bizProperty.getCode(), null);
                    i++;
                    continue;
                }
                i++;
            }

            if (isQueryData && StringUtils.isNotEmpty(queryField)) {
                //检验是否已关联流程实例
                isBind = getBizObjectFacade().checkBindWorkFlowInstance(userId, bizObject, queryField);
                if (log.isDebugEnabled()) {
                    log.debug("检验是否已关联流程实例66,bizObject={},queryField={},isBind={},isQueryData={}", JSONObject.toJSONString(bizObject), queryField, isBind, isQueryData);
                }
                if (isBind) {
                    ErrorValue errorValue15 = new ErrorValue();
                    errorValue15.setContent("表单已关联流程实例，不允许导入");
                    list.add(errorValue15);
                }
            }
            errList.addAll(list);
            if (CollectionUtils.isEmpty(errList) && (errList.size() < 1)) {
                if (ok && success) {
                    Object owner = map.get("owner");
                    if (Objects.nonNull(owner)) {
                        List<SelectionValue> owner1 = (List<SelectionValue>) owner;
                        SelectionValue selectionValue = owner1.get(0);
                        if (selectionValue != null && StringUtils.isNotEmpty(selectionValue.getId())) {
                            String id = selectionValue.getId();
                            map.put("owner", id);
                        }
                    }
                    //正常数据的子表的关联表单数据项处理
                    List<BizPropertyModel> child = properties.stream().filter(property -> Objects.equals(property.getPropertyType(), BizPropertyType.CHILD_TABLE)).collect(Collectors.toList());
                    if (CollectionUtils.isNotEmpty(child)) {
                        for (BizPropertyModel bizPropertyModel : child) {
                            BizSchemaModel subSchema = bizPropertyModel.getSubSchema();
                            List<BizPropertyModel> subProperties = subSchema.getProperties();
                            if (CollectionUtils.isEmpty(subProperties)) {
                                continue;
                            }
                            List<String> codes = subProperties.stream().filter(subProperty -> Objects.equals(subProperty.getPropertyType(), BizPropertyType.WORK_SHEET)).map(BizPropertyModel::getCode).collect(Collectors.toList());
                            if (CollectionUtils.isEmpty(codes)) {
                                continue;
                            }
                            String code = bizPropertyModel.getCode();
                            List<Map<String, Object>> subMap = (List<Map<String, Object>>) map.get(code);
                            if (CollectionUtils.isEmpty(subMap)) {
                                continue;
                            }
                            for (Map<String, Object> sub : subMap) {
                                if (MapUtils.isEmpty(sub)) {
                                    continue;
                                }
                                codes.forEach(subCode -> sub.put(subCode, Objects.isNull(sub.get(subCode)) ? null : ((BizObjectModel) sub.get(subCode)).getId()));
                            }

                        }
                    }
                    bizObject = new BizObjectModel(schemaCode, map, false);
                } else {
                    //需要二次导入的数据的关联表单数据处理
                    if (MapUtils.isNotEmpty(workSheet)) {
                        workSheet.keySet().forEach(key -> map.put(key, workSheet.get(key)));
                    }
                    secondList.add(map);
                }
            }

            if (CollectionUtils.isEmpty(errList) && (errList.size() < 1) && ok && success) {
                if (isQueryData && !isBind) {
                    bizObject.setStatus(BizObjectStatusType.NEW);
                    bizObject.setFormCode(formCode);
                    if (bizObject.get(DefaultPropertyType.SEQUENCE_STATUS.getCode()) == null) {
                        bizObject.setSequenceStatus(WorkflowInstanceStatus.COMPLETED.name());
                    }
                    bizObjects.add(bizObject);
                } else {
                    childMaps.add(map);
                }
            } else {
                List<String> content = list.stream().map(ErrorValue::getContent).collect(Collectors.toList());
                if (CollectionUtils.isNotEmpty(errList) && errList.size() > 0) {
                    mapTemplates.put("errInfo", content);
                    errorMaps.add(mapTemplates);
                }
            }
        }
    }

    //关联表单多选预处理
    private Map<String, Object> initMultWorkSheet(List<BizPropertyModel> properties, String schemaCode, String queryCode) {
        BizFormModel bizFormModel = getBizFormModel(schemaCode, queryCode);
        String publicJsonStr = bizFormModel.getPublishedAttributesJson();
        JSONObject publicJson = JSONObject.parseObject(publicJsonStr);
        Map<String, Object> multWorkMap = Maps.newHashMap();
        List<BizPropertyModel> multWorkProperties = properties.stream().filter(property -> property.getPropertyType() == BizPropertyType.MULT_WORK_SHEET).collect(Collectors.toList());
        multWorkProperties.stream().forEach(mult -> {
            if (Objects.nonNull(publicJson.getJSONObject(mult.getCode()))) {
                JSONObject options = publicJson.getJSONObject(mult.getCode()).getJSONObject("options");
                //取映射字段
                String mappings = options.getString("mappings");

                String mappingKeys = "";
                if (StringUtils.isNotEmpty(mappings)) {
                    String[] mappingStrs = mappings.split(";");
                    for (int mappingIndex = 0; mappingIndex < mappingStrs.length; mappingIndex++) {
                        String mappingKey = mappingStrs[mappingIndex].split(":")[0];
                        mappingKeys = mappingKeys + mappingKey + ";";
                        String mappingValue = mappingStrs[mappingIndex].split(":")[1];
                        if (mappingValue.startsWith("{") && mappingValue.endsWith("}")) {
                            mappingValue = mappingValue.replace("{", "").replace("}", "");
                            //组装映射关系map
                            multWorkMap.put(mult.getCode() + "_" + mappingKey, mappingValue);
                        }
                        //取映射关系两个子表一样的字段集合
                        List<String> sameBizProperties = getTwoChildSameCodeList(mappingKey, mappingValue);
                        //保存映射关系一样的字段结合
                        multWorkMap.put(mult.getCode() + "_" + mappingKey + "_list", sameBizProperties);
                    }
                    //保存映射关系目标模型的key集合
                    multWorkMap.put(mult.getCode() + "_mappingKeys", mappingKeys.substring(0, mappingKeys.length() - 1));
                }

            }

        });
        return multWorkMap;
    }

    protected BizFormModel getBizFormModel(String schemaCode, String queryCode) {
        BizQueryModel bizQueryModel = getBizQuery(schemaCode, queryCode, ClientType.PC);
        List<BizQueryActionModel> queryActions = bizQueryModel.getQueryActions();
        String sheetCode = schemaCode;
        //根据新增按钮去取sheetCode
        sheetCode = setSheetCode(queryActions, sheetCode);
        return getAppManagementFacade().getPublishBizForm(schemaCode, sheetCode);
    }

    protected String setSheetCode(List<BizQueryActionModel> queryActions, String sheetCode) {
        List<BizQueryActionModel> addActions = queryActions.stream().filter(queryAction -> queryAction.getQueryActionType() == QueryActionType.ADD).collect(Collectors.toList());
        if (CollectionUtil.isNotEmpty(addActions)) {
            BizQueryActionModel addAction = addActions.get(0);
            if (addAction.getQueryActionRelativeType() == QueryActionRelativeType.BIZSHEET) {
                if (Objects.nonNull(addAction.getRelativeCode())) {
                    return addAction.getRelativeCode();
                } else {
                    return sheetCode;
                }
            } else if (addAction.getQueryActionRelativeType() == QueryActionRelativeType.WORKFLOW) {
                String workflowTempCode = addAction.getRelativeCode();
                FormRuntimeHandler formRuntimeHandler = new FormRuntimeHandler(getDubboConfigService());
                return formRuntimeHandler.getWorkflowSheetCode(workflowTempCode);
            } else {
                return sheetCode;
            }
        }
        return sheetCode;
    }

    private List<String> getTwoChildSameCodeList(String mappingKey, String mappingValue) {
        BizSchemaModel firstMultChild = getAppManagementFacade().getBizSchemaBySchemaCode(mappingKey, true);
        BizSchemaModel secondMultChild = getAppManagementFacade().getBizSchemaBySchemaCode(mappingValue, true);
        List<BizPropertyModel> firstMutlChildProperties = firstMultChild.getProperties();
        List<BizPropertyModel> secondMutlChildProperties = secondMultChild.getProperties();
        return firstMutlChildProperties.stream().filter(firstMutlChildProperty -> secondMutlChildProperties.stream()
                .anyMatch(secondMutlChildProperty -> firstMutlChildProperty.getCode().equals(secondMutlChildProperty.getCode()) && firstMutlChildProperty.getPropertyType() == secondMutlChildProperty.getPropertyType()) && firstMutlChildProperty.getDefaultProperty() != Boolean.TRUE)
                .collect(Collectors.toList())
                .stream().map(BizPropertyModel::getCode).collect(Collectors.toList());
    }

    //子表格式校验
    private boolean checkChild(Map<String, Object> params, Map<String, Object> map, String code, Map<String, Object> mapTemplate,
                               List<Object> errList, boolean ok, Map<String, List<BizPropertyModel>> childPropertyMaps,
                               String corpId, DepartmentModel rootDept, OrgType orgType, BizFormModel bizFormModel) {

        //错误的map集合
        Map<String, Object> childErrorMap = Maps.newLinkedHashMap();
        boolean success = true;
        BizPropertyModel bizProperty1 = (BizPropertyModel) params.get("bizProperty");
        int i = (int) params.get("i");
        Object errorList = params.get("list");
        List<ErrorValue> list = (List<ErrorValue>) errorList;
        Object notEmpty1 = params.get("notEmpty");
        boolean notEmpty11 = (boolean) notEmpty1;
        String childName = bizProperty1.getName();

        Object childValues = map.get(code);
        if (Objects.isNull(childValues)) {
            if (notEmpty11) {
                ErrorValue errorValue20 = new ErrorValue();
                errorValue20.setContent(childName + (notEmpty11 ? ",不能为空!" : ",可以为空!"));
                list.add(errorValue20);
                i++;
                return success;
            }
            map.put(code, Lists.newArrayList());
        }
        List<Map<String, Object>> childList = Lists.newArrayList();

        List<Map<String, Object>> childs = (List<Map<String, Object>>) childValues;
        List<BizPropertyModel> properties = childPropertyMaps.get(code);

        //错误数据集合
        List<Map<String, Object>> childErrors = Lists.newArrayList();
        if (CollectionUtils.isNotEmpty(childs)) {

            for (Map<String, Object> child : childs) {
                List<ErrorValue> errorLists = Lists.newArrayList();
                Map<String, Object> childMapTemplate = Maps.newLinkedHashMap();
                if (MapUtils.isEmpty(child)) {
                    continue;
                }
                List<String> codes = properties.stream().map(BizPropertyModel::getCode).collect(Collectors.toList());
                for (String propertyCode : codes) {
                    childMapTemplate.put(propertyCode, child.get(propertyCode));
                }
                Map<String, Object> childMap = Maps.newHashMap();
                for (String key : child.keySet()) {
                    List<BizPropertyModel> bizPropertys = properties.stream().filter(propertyModel -> Objects.equals(propertyModel.getCode(), key)).collect(Collectors.toList());
                    BizPropertyModel bizProperty = bizPropertys.get(0);
                    Boolean notEmpty = bizProperty.getPropertyEmpty();
                    String name = bizProperty.getName();
                    BizPropertyType propertyType = bizProperty.getPropertyType();
                    List<String> defaultCodes = Arrays.stream(DefaultPropertyType.values()).map(DefaultPropertyType::getCode).collect(Collectors.toList());
                    Object value = child.get(key);
                    switch (propertyType) {

                        case WORK_SHEET:
                            checkChildWorkSheet(childMap, value, notEmpty, name, errorLists, bizProperty, childName);
                            break;
                        case MULT_WORK_SHEET:
                            checkChildMultWorkSheet(childMap, value, notEmpty, name, errorLists, bizProperty, childName);
                            break;

                        case NUMERICAL:
                            checkChildNumerical(childMap, value, notEmpty, name, errorLists, bizProperty, childName);
                            break;

                        case DATE:
                            checkChildDate(childMap, value, notEmpty, name, errorLists, bizProperty, childName);
                            break;

                        case LOGICAL:
                            checkChildLogical(childMap, value, notEmpty, name, errorLists, bizProperty, childName);
                            break;

                        case LONG_TEXT:
                            checkChildLongText(childMap, value, notEmpty, name, errorLists, bizProperty, childName);
                            break;

                        case SHORT_TEXT:
                            checkChildShortText(defaultCodes, childMap, value, notEmpty, name,
                                    errorLists, bizProperty, childName, bizFormModel, code);
                            break;

                        case SELECTION:
                            ok = checkChildSelection(childMap, value, notEmpty, bizProperty, ok, corpId, rootDept, orgType);
                            break;

                        default:
                            break;
                    }

                }

                List<String> content = errorLists.stream().map(ErrorValue::getContent).collect(Collectors.toList());
                if (CollectionUtils.isNotEmpty(content)) {
                    log.debug("每行字表的错误信息: --{}", content);
                }
                errList.addAll(content);
                childMapTemplate.put("errInfo", content);
                childErrors.add(childMapTemplate);
                childList.add(childMap);
            }
        }
        childErrorMap.put(code, childErrors);
        mapTemplate.putAll(childErrorMap);
        map.put(code, childList);
        i++;
        return ok;
    }

    //关联表单格式校验
    private void checkWorkSheet(Map<String, Object> params, Map<String, Object> map, Map<String, Object> workSheet) {

        //参数拿出来
        int i = (int) params.get("i");
        Boolean notEmpty = (boolean) params.get("notEmpty");
        List<String> editCodes = (List<String>) params.get("editCodes");
        List<ErrorValue> list = (List<ErrorValue>) params.get("list");
        BizPropertyModel bizProperty = (BizPropertyModel) params.get("bizProperty");
        String value = String.valueOf(params.get("value"));
        List<String> headers = (List<String>) params.get("headers");
        params.get("key");
        params.get("defaultCodes");
        params.get("textInfos");
        params.get("radioInfos");
        params.get("checkboxInfos");
        params.get("dropdownInfos");
        String name = bizProperty.getName();
        //
        //主表
        Boolean isQueryData = true;
        //子表
        if (CollectionUtils.isNotEmpty(editCodes)) {
            isQueryData = false;
        }
        if (notEmpty && StringUtils.isEmpty(value)) {
            ErrorValue errorValue1 = new ErrorValue();
            errorValue1.setContent(name + (notEmpty ? ",不能为空!" : ",可以为空!"));
            list.add(errorValue1);
            i++;
            return;
        }
        if (StringUtils.isNotEmpty(value)) {
            if (!isQueryData && !editCodes.contains(bizProperty.getCode())) {
                map.put(bizProperty.getCode(), null);
                i++;
                return;
            }
            FilterExpression filterExpression = Q.it("name", FilterExpression.Op.Eq, value);
            BizObjectQueryModel bizObjectQueryObject = new BizObjectQueryModel();
            PageableImpl pageable = new PageableImpl(0, 10000000);
            log.info("bizProperty关联表单的数据：schemaCode={}", JSONObject.toJSONString(bizProperty.getRelativeCode()));
            bizObjectQueryObject.setSchemaCode(bizProperty.getRelativeCode());
            bizObjectQueryObject.setFilterExpr(filterExpression);
            bizObjectQueryObject.setPageable(pageable);
            BizQueryModel bizQuery = getBizQuery(bizProperty.getRelativeCode(), null, ClientType.PC);
            bizObjectQueryObject.setQueryCode(bizQuery.getCode());
            bizObjectQueryObject.setClientType(ClientType.PC);
            Page<BizObjectModel> dataTempalte = getBizObjectFacade().queryBizObjects(bizObjectQueryObject);
            if (dataTempalte != null && CollectionUtils.isNotEmpty(dataTempalte.getContent())) {
                if (isQueryData) {
                    map.put(bizProperty.getCode(), dataTempalte.getContent().get(0).getId());
                    workSheet.put(bizProperty.getCode(), dataTempalte.getContent().get(0));
                } else {
                    Map<String, Object> mapChild = new HashMap<>();
                    mapChild.put("name", value);
                    mapChild.put("id", dataTempalte.getContent().get(0).getId());
                    mapChild.put("schemaCode", bizProperty.getRelativeCode());
                    map.put(bizProperty.getCode(), mapChild);
                }
            } else {
                ErrorValue errorValue2 = new ErrorValue();
                errorValue2.setContent(name + "：关联表单不存在!");
                list.add(errorValue2);
                i++;
                return;
            }
        }
        i++;
        return;

    }

    //关联表单多选格式校验
    private void checkMultWorkSheet(Map<String, Object> params, Map<String, Object> map, Map<String, Object> workSheet) {

        //参数拿出来
        int i = (int) params.get("i");
        Boolean notEmpty = (boolean) params.get("notEmpty");
        List<String> editCodes = (List<String>) params.get("editCodes");
        List<ErrorValue> list = (List<ErrorValue>) params.get("list");
        BizPropertyModel bizProperty = (BizPropertyModel) params.get("bizProperty");
        String value = String.valueOf(params.get("value"));
        List<String> headers = (List<String>) params.get("headers");
        params.get("key");
        params.get("defaultCodes");
        params.get("textInfos");
        params.get("radioInfos");
        params.get("checkboxInfos");
        params.get("dropdownInfos");
        Map<String, Object> multWorkMap = (Map<String, Object>) params.get("multWorkMap");
        String name = bizProperty.getName();
        //
        //主表
        Boolean isQueryData = true;
        //子表
        if (CollectionUtils.isNotEmpty(editCodes)) {
            isQueryData = false;
        }
        if (notEmpty && StringUtils.isEmpty(value)) {
            ErrorValue errorValue1 = new ErrorValue();
            errorValue1.setContent(name + (notEmpty ? ",不能为空!" : ",可以为空!"));
            list.add(errorValue1);
            i++;
            return;
        }
        if (StringUtils.isNotEmpty(value)) {
            if (!isQueryData && !editCodes.contains(bizProperty.getCode())) {
                map.put(bizProperty.getCode(), null);
                i++;
                return;
            }
            String[] values = value.split(";");
            String ids = "";
            String names = "";
            String showName = "";
            for (int multIdIndex = 0; multIdIndex < values.length; multIdIndex++) {
                String multName = values[multIdIndex];
                FilterExpression filterExpression = Q.it("name", FilterExpression.Op.Eq, multName);
                BizObjectQueryModel bizObjectQueryObject = new BizObjectQueryModel();
                PageableImpl pageable = new PageableImpl(0, 10000000);
                log.info("bizProperty关联表单的数据：schemaCode={}", JSONObject.toJSONString(bizProperty.getRelativeCode()));
                //对关联表单多选进行特殊处理
                GetBizQueryOptions getBizQueryOptions = new GetBizQueryOptions(bizProperty, multWorkMap).invoke();
                BizObjectQueryModel.Options options = getBizQueryOptions.getOptions();
                List<String> queryCodes = getBizQueryOptions.getQueryCodes();
                queryCodes.add(bizProperty.getRelativePropertyCode());
                bizObjectQueryObject.setOptions(options);
                bizObjectQueryObject.setSchemaCode(bizProperty.getRelativeCode());
                bizObjectQueryObject.setFilterExpr(filterExpression);
                bizObjectQueryObject.setPageable(pageable);
                BizQueryModel bizQuery = getBizQuery(bizProperty.getRelativeCode(), null, ClientType.PC);
                bizObjectQueryObject.setQueryCode(bizQuery.getCode());
                bizObjectQueryObject.setClientType(ClientType.PC);
                Page<BizObjectModel> dataTempalte = getBizObjectFacade().queryBizObjects(bizObjectQueryObject);
                if (dataTempalte != null && CollectionUtils.isNotEmpty(dataTempalte.getContent())) {
                    //关联表单多选ID都是;分割
                    ids = ids + dataTempalte.getContent().get(0).getId() + ";";
                    if (dataTempalte.getContent().get(0).getData().get(bizProperty.getRelativePropertyCode()) != null) {
                        showName = showName + dataTempalte.getContent().get(0).getData().get(bizProperty.getRelativePropertyCode()) + ";";
                    }
                    //目标模型数据只取第一个
                    BizObjectModel bizObjectModel = dataTempalte.getContent().get(0);
                    if (Objects.nonNull(multWorkMap.get(bizProperty.getCode() + "_mappingKeys"))) {
                        queryCodes.remove("id");
                        queryCodes.remove(bizProperty.getRelativePropertyCode());
                        queryCodes.stream().forEach(queryCode -> {
                            //取当前的子表schemaCode
                            String childCode = (String) multWorkMap.get(bizProperty.getCode() + "_" + queryCode);
                            //取相同的子表字段
                            List<String> sameCodes = (List<String>) multWorkMap.get(bizProperty.getCode() + "_" + queryCode + "_list");
                            //取目标模型子表数据
                            List<Map<String, Object>> childDatas = (List<Map<String, Object>>) bizObjectModel.getData().get(queryCode);
                            //用相同的子表字段组装当前表单的子表数据
                            List<Map<String, Object>> newChildDatas = Lists.newArrayList();
                            childDatas.stream().forEach(childData -> {
                                Map<String, Object> targetMap = Maps.newHashMap();
                                //targetMap.put("id",childData.get("id"));
                                sameCodes.stream().forEach(sameCode -> targetMap.put(sameCode, childData.get(sameCode)));
                                newChildDatas.add(targetMap);

                            });
                            map.put(childCode, newChildDatas);
                        });
                    }
                } else {
                    ErrorValue errorValue2 = new ErrorValue();
                    errorValue2.setContent(name + "：关联表单多选不存在!");
                    list.add(errorValue2);
                    i++;
                    return;
                }
            }
            ids = ids.substring(0, ids.length() - 1);
            if (StringUtils.isNotBlank(showName)) {
                showName = showName.substring(0, showName.length() - 1);
            }
            if (isQueryData) {
                map.put(bizProperty.getCode(), ids);
            } else {
                Map<String, Object> mapChild = new HashMap<>();
                mapChild.put("name", value);
                mapChild.put("showName", showName);
                mapChild.put("id", ids);
                mapChild.put("schemaCode", bizProperty.getRelativeCode());
                map.put(bizProperty.getCode(), mapChild);
            }

        }
        i++;
        return;

    }

    //子表关联表单格式校验
    private void checkChildWorkSheet(Map<String, Object> map, Object value, Boolean notEmpty, String name, List<ErrorValue> list, BizPropertyModel bizProperty, String childName) {
        if (notEmpty && Objects.isNull(value)) {
            ErrorValue errorValue1 = new ErrorValue();
            errorValue1.setContent(childName + "-" + name + (notEmpty ? ",不能为空!" : ",可以为空!"));
            list.add(errorValue1);
            return;
        }

        String value1 = Objects.isNull(value) ? "" : value.toString();

        if (StringUtils.isNotEmpty(value1)) {
            FilterExpression filterExpression = Q.it("name", FilterExpression.Op.Eq, value);
            BizObjectQueryModel bizObjectQueryObject = new BizObjectQueryModel();
            PageableImpl pageable = new PageableImpl(0, Integer.MAX_VALUE);
            String s = ReflectionToStringBuilder.toString(bizProperty, ToStringStyle.SHORT_PREFIX_STYLE);
            log.info("bizProperty关联表单的数据：schemaCode={}", JSONObject.toJSONString(bizProperty.getRelativeCode()));
            bizObjectQueryObject.setSchemaCode(bizProperty.getRelativeCode());
            bizObjectQueryObject.setFilterExpr(filterExpression);
            bizObjectQueryObject.setPageable(pageable);
            BizQueryModel bizQuery = getBizQuery(bizProperty.getRelativeCode(), null, ClientType.PC);
            bizObjectQueryObject.setQueryCode(bizQuery.getCode());
            log.info("关联的code：--{}", bizQuery.getCode());
            bizObjectQueryObject.setClientType(ClientType.PC);
            Page<BizObjectModel> dataTempalte = getBizObjectFacade().queryBizObjects(bizObjectQueryObject);
            log.info("关联的模型数据：--{},--{},--{}", dataTempalte, dataTempalte.getContent(), dataTempalte.getTotal());
            if (dataTempalte != null && CollectionUtils.isNotEmpty(dataTempalte.getContent())) {
                map.put(bizProperty.getCode(), dataTempalte.getContent().get(0));
            } else {
                ErrorValue errorValue2 = new ErrorValue();
                errorValue2.setContent(childName + "-" + name + "：关联表单不存在!");
                list.add(errorValue2);
                return;
            }
        }
        return;
    }

    //子表关联表单格式校验
    private void checkChildMultWorkSheet(Map<String, Object> map, Object value, Boolean notEmpty, String name, List<ErrorValue> list, BizPropertyModel bizProperty, String childName) {
        if (notEmpty && Objects.isNull(value)) {
            ErrorValue errorValue1 = new ErrorValue();
            errorValue1.setContent(childName + "-" + name + (notEmpty ? ",不能为空!" : ",可以为空!"));
            list.add(errorValue1);
            return;
        }

        String value1 = Objects.isNull(value) ? "" : value.toString();

        if (StringUtils.isNotEmpty(value1)) {
            String[] values = value1.split(";");
            String ids = "";

            for (int multChildIdIndex = 0; multChildIdIndex < values.length; multChildIdIndex++) {
                FilterExpression filterExpression = Q.it("name", FilterExpression.Op.Eq, values[multChildIdIndex]);
                BizObjectQueryModel bizObjectQueryObject = new BizObjectQueryModel();
                PageableImpl pageable = new PageableImpl(0, Integer.MAX_VALUE);
                String s = ReflectionToStringBuilder.toString(bizProperty, ToStringStyle.SHORT_PREFIX_STYLE);
                log.info("bizProperty关联表单的数据：schemaCode={}", JSONObject.toJSONString(bizProperty.getRelativeCode()));
                bizObjectQueryObject.setSchemaCode(bizProperty.getRelativeCode());
                bizObjectQueryObject.setFilterExpr(filterExpression);
                bizObjectQueryObject.setPageable(pageable);
                BizQueryModel bizQuery = getBizQuery(bizProperty.getRelativeCode(), null, ClientType.PC);
                bizObjectQueryObject.setQueryCode(bizQuery.getCode());
                log.info("关联的code：--{}", bizQuery.getCode());
                bizObjectQueryObject.setClientType(ClientType.PC);
                Page<BizObjectModel> dataTempalte = getBizObjectFacade().queryBizObjects(bizObjectQueryObject);
                log.info("关联的模型数据：--{},--{},--{}", dataTempalte, dataTempalte.getContent(), dataTempalte.getTotal());

                if (dataTempalte != null && CollectionUtils.isNotEmpty(dataTempalte.getContent())) {
                    ids = ids + dataTempalte.getContent().get(0).getId() + ";";
                } else {
                    ErrorValue errorValue2 = new ErrorValue();
                    errorValue2.setContent(childName + "-" + name + "：关联表单多选不存在!");
                    list.add(errorValue2);
                    return;
                }
            }
            ids = ids.substring(0, ids.length() - 1);
            map.put(bizProperty.getCode(), ids);
        }
    }

    //导入的数值格式校验
    private void checkNumerical(Map<String, Object> params, Map<String, Object> map) {
        //参数拿出来
        int i = (int) params.get("i");
        boolean notEmpty = (boolean) params.get("notEmpty");
        List<String> editCodes = (List<String>) params.get("editCodes");
        List<ErrorValue> list = (List<ErrorValue>) params.get("list");
        BizPropertyModel bizProperty = (BizPropertyModel) params.get("bizProperty");
        String value = String.valueOf(params.get("value"));
        String key = String.valueOf(params.get("key"));
        params.get("defaultCodes");
        params.get("textInfos");
        params.get("radioInfos");
        params.get("checkboxInfos");
        params.get("dropdownInfos");
        String name = bizProperty.getName();


        //主表
        boolean isQueryData = true;
        //子表
        if (CollectionUtils.isNotEmpty(editCodes)) {
            isQueryData = false;
        }
        if (!isQueryData && !editCodes.contains(bizProperty.getCode())) {
            map.put(bizProperty.getCode(), null);
            i++;
            return;
        }
        if (notEmpty && StringUtils.isEmpty(value)) {
            ErrorValue errorValue15 = new ErrorValue();
            errorValue15.setContent(name + "：该项仅支持数值填写" + (notEmpty ? ",不能为空!" : ",可以为空!"));
            list.add(errorValue15);
            i++;
            return;
        }
        if (StringUtils.isNotEmpty(value)) {
            if (PropertyValidateHelper.validateNumberOverMaxLength(value)) {
                ErrorValue errorValue3 = new ErrorValue();
                errorValue3.setContent("【" + name + "】超过限制，最大长度16位，精度8位（8位小数）；");
                list.add(errorValue3);
                i++;
                return;
            }
            if (!PropertyValidateHelper.validateNumerical(value, notEmpty)) {
                ErrorValue errorValue3 = new ErrorValue();
                errorValue3.setContent("【" + name + "】输入格式不对，仅支持整数、1位小数、2位小数、3位小数、4位小数、5位小数、6位小数、7位小数和8位小数共9种数值格式；");
                list.add(errorValue3);
                i++;
                return;
            }
        }
        map.put(bizProperty.getCode(), map.get(key) == null ? null : map.get(key));
        i++;
    }

    //导入子表的数值格式校验
    private void checkChildNumerical(Map<String, Object> map, Object value, Boolean notEmpty, String name, List<ErrorValue> list, BizPropertyModel bizProperty, String childName) {
        //参数拿出来
        if (Objects.nonNull(value)) {
            String number = value.toString();
            if (!PropertyValidateHelper.validateNumerical(number, notEmpty)) {
                ErrorValue errorValue3 = new ErrorValue();
                errorValue3.setContent("【" + childName + "-" + name + "】输入格式不对，仅支持整数、1位小数、2位小数、3位小数、4位小数、5位小数、6位小数、7位小数和8位小数共9种数值格式；");
                list.add(errorValue3);
                return;
            }
        }
        if (notEmpty && (Objects.isNull(value))) {
            ErrorValue errorValue15 = new ErrorValue();
            errorValue15.setContent(childName + "-" + name + "：该项仅支持数值填写" + (notEmpty ? ",不能为空!" : ",可以为空!"));
            list.add(errorValue15);
            return;
        }
        map.put(bizProperty.getCode(), value == null ? null : value);
    }

    //校验导入的日期格式
    private void checkDate(Map<String, Object> params, Map<String, Object> map) {
        //参数拿出来
        int i = (int) params.get("i");
        List<BizPropertyType> propertyTypes = (List<BizPropertyType>) params.get("propertyTypes");
        boolean notEmpty = (boolean) params.get("notEmpty");
        List<String> editCodes = (List<String>) params.get("editCodes");
        List<ErrorValue> list = (List<ErrorValue>) params.get("list");
        BizPropertyModel bizProperty = (BizPropertyModel) params.get("bizProperty");
        String value = Objects.isNull(params.get("value")) ? "" : params.get("value").toString();
        List<String> headers = (List<String>) params.get("headers");
        String key = String.valueOf(params.get("key"));
        params.get("defaultCodes");
        params.get("textInfos");
        params.get("radioInfos");
        params.get("checkboxInfos");
        params.get("dropdownInfos");
        //
        String name = bizProperty.getName();

        //主表
        boolean isQueryData = true;
        //子表
        if (CollectionUtils.isNotEmpty(editCodes)) {
            isQueryData = false;
        }
        if (!isQueryData && !editCodes.contains(bizProperty.getCode())) {
            map.put(bizProperty.getCode(), null);
            i++;
            return;
        }
        if (notEmpty && StringUtils.isEmpty(value)) {
            ErrorValue errorValue16 = new ErrorValue();
            errorValue16.setContent(name + "：该项仅支持日期填写" + (notEmpty ? ",不能为空!" : ",可以为空!"));
            list.add(errorValue16);
            i++;
            return;
        }
        if (StringUtils.isNotEmpty(value)) {
            if (!PropertyValidateHelper.isValidDates(value, notEmpty)) {
                ErrorValue errorValue4 = new ErrorValue();
                errorValue4.setContent("【" + name + "】输入格式不对，仅支持" + JSONArray.toJSONString(PropertyValidateHelper.supportsPatterns) + "4种日期格式;");
                list.add(errorValue4);
                i++;
                return;
            }
            map.put(bizProperty.getCode(), value);
            i++;
            return;
        }
        map.put(bizProperty.getCode(), null);
        i++;
        return;
    }

    //校验导入的时间格式
    private void checkTime(Map<String, Object> params, Map<String, Object> map) {
        //参数拿出来
        int i = (int) params.get("i");
        List<BizPropertyType> propertyTypes = (List<BizPropertyType>) params.get("propertyTypes");
        Boolean notEmpty = (boolean) params.get("notEmpty");
        List<String> editCodes = (List<String>) params.get("editCodes");
        List<ErrorValue> list = (List<ErrorValue>) params.get("list");
        BizPropertyModel bizProperty = (BizPropertyModel) params.get("bizProperty");
        String value = Objects.isNull(params.get("value")) ? "" : params.get("value").toString();
        List<String> headers = (List<String>) params.get("headers");
        String key = String.valueOf(params.get("key"));
        params.get("defaultCodes");
        params.get("textInfos");
        params.get("radioInfos");
        params.get("checkboxInfos");
        params.get("dropdownInfos");
        //
        String name = bizProperty.getName();

        //主表
        Boolean isQueryData = true;
        //子表
        if (CollectionUtils.isNotEmpty(editCodes)) {
            isQueryData = false;
        }
        if (!isQueryData && !editCodes.contains(bizProperty.getCode())) {
            map.put(bizProperty.getCode(), null);
            i++;
            return;
        }
        if (notEmpty && StringUtils.isEmpty(value)) {
            ErrorValue errorValue16 = new ErrorValue();
            errorValue16.setContent(name + "：该项仅支持时间填写" + (notEmpty ? ",不能为空!" : ",可以为空!"));
            list.add(errorValue16);
            i++;
            return;
        }
        if (StringUtils.isNotEmpty(value)) {

            if (!PropertyValidateHelper.isValidTime(value, notEmpty)) {
                ErrorValue errorValue4 = new ErrorValue();
                errorValue4.setContent("【" + name + "】输入格式不对，仅支持" + JSONArray.toJSONString(PropertyValidateHelper.supportsTimePatterns) + "2种时间格式;");
                list.add(errorValue4);
                i++;
                return;
            }
            map.put(bizProperty.getCode(), value);
            i++;
            return;
        }
        map.put(bizProperty.getCode(), null);
        i++;
        return;
    }

    //校验导入子表的日期格式
    private void checkChildDate(Map<String, Object> map, Object value, Boolean notEmpty, String name, List<ErrorValue> list, BizPropertyModel bizProperty, String childName) {

        if (notEmpty && Objects.isNull(value)) {
            ErrorValue errorValue16 = new ErrorValue();
            errorValue16.setContent(childName + "-" + name + "：该项仅支持日期填写" + (notEmpty ? ",不能为空!" : ",可以为空!"));
            list.add(errorValue16);
            return;
        }

        if (Objects.nonNull(value)) {
            String string = value.toString();
            if (!PropertyValidateHelper.isValidDates(string, notEmpty)) {
                ErrorValue errorValue4 = new ErrorValue();
                errorValue4.setContent("【" + childName + "-" + name + "】输入格式不对，仅支持" + JSONArray.toJSONString(PropertyValidateHelper.supportsPatterns) + "4种日期格式;");
                list.add(errorValue4);
                return;
            }
            map.put(bizProperty.getCode(), value);
            return;
        }
        map.put(bizProperty.getCode(), null);
        return;
    }

    //校验导入的逻辑类型数据格式
    private void checkLogical(Map<String, Object> params, Map<String, Object> map) {
        //参数拿出来
        int i = (int) params.get("i");
        List<BizPropertyType> propertyTypes = (List<BizPropertyType>) params.get("propertyTypes");
        Boolean notEmpty = (boolean) params.get("notEmpty");
        List<String> editCodes = (List<String>) params.get("editCodes");
        List<ErrorValue> list = (List<ErrorValue>) params.get("list");
        BizPropertyModel bizProperty = (BizPropertyModel) params.get("bizProperty");
        String value = Objects.isNull(params.get("value")) ? "" : params.get("value").toString();
        List<String> headers = (List<String>) params.get("headers");
        String key = String.valueOf(params.get("key"));
        params.get("defaultCodes");
        params.get("textInfos");
        params.get("radioInfos");
        params.get("checkboxInfos");
        params.get("dropdownInfos");
        //
        String name = bizProperty.getName();

        //主表
        boolean isQueryData = true;
        //子表
        if (CollectionUtils.isNotEmpty(editCodes)) {
            isQueryData = false;
        }
        if (!isQueryData && !editCodes.contains(bizProperty.getCode())) {
            map.put(bizProperty.getCode(), null);
            i++;
            return;
        }
        value = map.get(key) == null ? "" : map.get(key).toString();
        if (!PropertyValidateHelper.validateLogical(value, notEmpty)) {
            ErrorValue errorValue5 = new ErrorValue();
            Object mapValue = (map.get(key) == null) ? "" : "-[" + map.get(key) + "]";
            errorValue5.setContent(name + (notEmpty ? ",不能为空!" : ",可以为空!") + "内容格式错误" + mapValue + "," + "支持类型为：" + JSONArray.toJSONString(PropertyValidateHelper.boolStringValues));
            list.add(errorValue5);
            i++;
            return;
        }
        if (!isQueryData) {
            if ("是".equals(value) || "1".equals(value) || "true".equals(value)) {
                map.put(bizProperty.getCode(), true);
            } else if ("否".equals(value) || "0".equals(value) || "false".equals(value)) {
                map.put(bizProperty.getCode(), false);
            }
        } else {
            if ("是".equals(value) || "1".equals(value) || "true".equals(value)) {
                map.put(bizProperty.getCode(), true);
            } else if ("否".equals(value) || "0".equals(value) || "false".equals(value)) {
                map.put(bizProperty.getCode(), false);
            }
        }
        i++;
        return;
    }

    //校验导入的子表逻辑类型数据格式
    private void checkChildLogical(Map<String, Object> map, Object value, Boolean notEmpty, String name, List<ErrorValue> list, BizPropertyModel bizProperty, String childName) {
        String values = Objects.isNull(value) ? "" : value.toString();
        if (!PropertyValidateHelper.validateLogical(String.valueOf(values), notEmpty)) {
            ErrorValue errorValue5 = new ErrorValue();
            Object mapValue = (Objects.isNull(value)) ? "" : "-[" + value + "]";
            errorValue5.setContent(childName + "-" + name + (notEmpty ? ",不能为空!" : ",可以为空!") + "内容格式错误" + mapValue + "," + "支持类型为：" + JSONArray.toJSONString(PropertyValidateHelper.boolStringValues));
            list.add(errorValue5);
            return;
        }
        if ("是".equals(value) || "1".equals(value) || "true".equals(value)) {
            map.put(bizProperty.getCode(), true);
        } else if ("否".equals(value) || "0".equals(value) || "false".equals(value)) {
            map.put(bizProperty.getCode(), false);
        }
    }

    //校验导入的长文本数据格式
    @SuppressWarnings("unckecked")
    private void checkLongText(Map<String, Object> params, Map<String, Object> map, Map<String, String> textInfos) {
        //参数拿出来
        int i = (int) params.get("i");
        boolean notEmpty = (boolean) params.get("notEmpty");
        List<String> editCodes = (List<String>) params.get("editCodes");
        List<ErrorValue> list = (List<ErrorValue>) params.get("list");
        BizPropertyModel bizProperty = (BizPropertyModel) params.get("bizProperty");
        String value = Objects.isNull(params.get("value")) ? "" : params.get("value").toString();
        String name = bizProperty.getName();

        //主表
        boolean isQueryData = true;
        //子表
        if (CollectionUtils.isNotEmpty(editCodes)) {
            isQueryData = false;
        }

        if (notEmpty && StringUtils.isEmpty(value)) {
            ErrorValue errorValue20 = new ErrorValue();
            errorValue20.setContent(name + (notEmpty ? ",不能为空!" : ",可以为空!"));
            list.add(errorValue20);
            i++;
            return;
        }

        Integer maxLength = 16777215;
        if (!PropertyValidateHelper.validateShortText(value, maxLength, notEmpty)) {
            ErrorValue errorValue6 = new ErrorValue();
            errorValue6.setContent(name + "：长文本数据类型，内容太多，超出16777215个字符限制，请修改！");
            list.add(errorValue6);
            i++;
            return;
        }

        if (!isQueryData) {
            if (CollectionUtils.isNotEmpty(textInfos.keySet()) && textInfos.containsKey(bizProperty.getCode())) {
                if (value.length() > Integer.parseInt(textInfos.get(bizProperty.getCode()))) {
                    map.put(bizProperty.getCode(), value.substring(0, Integer.parseInt(textInfos.get(bizProperty.getCode()))));
                    i++;
                    return;
                }
            }
        }
        map.put(bizProperty.getCode(), value);
        i++;
        return;
    }

    //校验导入子表的长文本数据格式
    private void checkChildLongText(Map<String, Object> map, Object value, Boolean notEmpty, String name, List<ErrorValue> list, BizPropertyModel bizProperty, String childName) {
        //参数拿出来
        if (notEmpty && Objects.isNull(value)) {
            ErrorValue errorValue20 = new ErrorValue();
            errorValue20.setContent(childName + "-" + name + (notEmpty ? ",不能为空!" : ",可以为空!"));
            list.add(errorValue20);
            return;
        }
        String values = Objects.isNull(value) ? "" : value.toString();
        Integer maxLength = 16777215;
        if (!PropertyValidateHelper.validateShortText(String.valueOf(values), maxLength, notEmpty)) {
            ErrorValue errorValue6 = new ErrorValue();
            errorValue6.setContent(childName + "-" + name + "：长文本数据类型，内容太多，超出16777215个字符限制，请修改！");
            list.add(errorValue6);
            return;
        }
        map.put(bizProperty.getCode(), value);
    }

    //说明：未更改成功的数据结构：放入一个CompMatchInfo对象，之前是一个值，如null
    //见代码：map.put(bizProperty.getCode(),new CompMatchInfo<String>(null,true));
    //原有匹配成功数据结构："Province": "河北省"，未匹配数据结构："Province": {"value": null,"marked": true }

    //校验业务项短文本和系统数据项短文本
    @SuppressWarnings("unchecked")
    private void checkShortText(List<String> defaultCodes, Map<String, String> textInfos,
                                Map<String, String> radioInfos, Map<String, String> checkboxInfos,
                                Map<String, String> dropdownInfos, Map<String, Object> params, Map<String, Object> map,
                                FileOperationResult operationResult, Map<String, Map<String, String>> dropdownInfos2,
                                BizFormModel bizFormModel) {

        //参数拿出来
        int i = (int) params.get("i");
        boolean notEmpty = (boolean) params.get("notEmpty");
        List<String> editCodes = (List<String>) params.get("editCodes");
        List<ErrorValue> list = (List<ErrorValue>) params.get("list");
        BizPropertyModel bizProperty = (BizPropertyModel) params.get("bizProperty");
        String value = Objects.isNull(params.get("value")) ? "" : params.get("value").toString();
        String key = String.valueOf(params.get("key"));
        String name = bizProperty.getName();


        //主表
        boolean isQueryData = true;
        //子表
        if (CollectionUtils.isNotEmpty(editCodes)) {
            isQueryData = false;
        }
        if (!isQueryData && !editCodes.contains(bizProperty.getCode())) {
            map.put(bizProperty.getCode(), null);
            i++;
            return;
        }
        //需要校验长度
        if (notEmpty && StringUtils.isEmpty(value)) {
            ErrorValue errorValue17 = new ErrorValue();
            errorValue17.setContent(name + (notEmpty ? ",不能为空!" : ",可以为空!"));
            list.add(errorValue17);
            i++;
            return;
        }
        Integer maxLength = 200;
        if (!PropertyValidateHelper.validateShortText(value, maxLength, notEmpty)) {
            ErrorValue errorValue6 = new ErrorValue();
            errorValue6.setContent(name + "：为短文本数据类型，内容太多，超出200个字符限制，请修改！");
            list.add(errorValue6);
            i++;
            return;
        }
        //todo:测试和产品确认
        //系统数据项人或部门

        if (StringUtils.isNotEmpty(value) && defaultCodes.contains(bizProperty.getCode())) {
            if (bizProperty.getCode().equals(DefaultPropertyType.SEQUENCE_STATUS.getCode())) {
                if (value.equals(WorkflowInstanceStatus.DRAFT.getName()) || value.equals(String.valueOf(WorkflowInstanceStatus.DRAFT.getIndex())) || value.equals(WorkflowInstanceStatus.DRAFT.name())) {
                    value = WorkflowInstanceStatus.DRAFT.name();
                    map.put(DefaultPropertyType.SEQUENCE_STATUS.getCode(), value);
                } else if (value.equals(WorkflowInstanceStatus.COMPLETED.getName()) || value.equals(String.valueOf(WorkflowInstanceStatus.COMPLETED.getIndex())) || value.equals(WorkflowInstanceStatus.COMPLETED.name())) {
                    value = WorkflowInstanceStatus.COMPLETED.name();
                    map.put(DefaultPropertyType.SEQUENCE_STATUS.getCode(), value);
                } else {
                    if (StringUtils.isEmpty(value)) {
                        value = WorkflowInstanceStatus.DRAFT.name();
                        map.put(DefaultPropertyType.SEQUENCE_STATUS.getCode(), value);
                    } else {
                        ErrorValue errorValue7 = new ErrorValue();
                        Object mapValue = (map.get(key) == null) ? "" : "-[" + map.get(key) + "]";
                        errorValue7.setContent(name + (notEmpty ? ",不能为空!" : ",可以为空!") + "内容格式错误" + mapValue + "," + "不支持数字填写，填写内容可为：草稿，已完成");
                        list.add(errorValue7);
                        i++;
                        return;
                    }
                }
            }
        } else {
            //子表导入，非列表带入，匹配
            if (!isQueryData && StringUtils.isNotEmpty(value)) {
                if (CollectionUtils.isNotEmpty(textInfos.keySet()) && textInfos.keySet().contains(bizProperty.getCode())) {
                    if (value.length() > Integer.parseInt(textInfos.get(bizProperty.getCode()))) {
                        map.put(bizProperty.getCode(), value.substring(0, Integer.parseInt(textInfos.get(bizProperty.getCode()))));
                        i++;
                        return;
                    }
                }
                if (CollectionUtils.isNotEmpty(radioInfos.keySet()) && radioInfos.keySet().contains(bizProperty.getCode())) {
                    if (!Arrays.asList(radioInfos.get(bizProperty.getCode()).split(";")).contains(value)) {
                        //map.put(bizProperty.getCode(), null);
                        map.put(bizProperty.getCode(), new CompMatchInfo<String>(null, true));
                        operationResult.setRadioMarkedCount(operationResult.getRadioMarkedCount() + 1);
                        i++;
                        return;
                    }
                }
                //if (CollectionUtils.isNotEmpty(dropdownInfos.keySet()) && dropdownInfos.keySet().contains(bizProperty.getCode())) {
                if (CollectionUtils.isNotEmpty(dropdownInfos2.keySet()) && dropdownInfos2.keySet().contains(bizProperty.getCode())) {
                    //String setting = dropdownInfos.get(bizProperty.getCode());
                    Map<String, String> smap = dropdownInfos2.get(bizProperty.getCode());
                    String setting = smap.get(bizProperty.getCode());

                    //multi 排除下拉框多选,之前下拉框多选有问题
                    boolean isSchemaDropdown = setting != null && setting.contains("schemaCode") && setting.contains("appCode") && setting.contains("sheetDataItem") && !setting.contains(";");
                    //if (!isSchemaDropdown && !Arrays.asList(dropdownInfos.get(bizProperty.getCode()).split(";")).contains(value)) {
                    if (!isSchemaDropdown && !Arrays.asList(smap.get(bizProperty.getCode()).split(";")).contains(value)
                            && "false".equals(smap.get("multi"))) {
                        //map.put(bizProperty.getCode(), null);
                        map.put(bizProperty.getCode(), new CompMatchInfo<String>(null, true));
                        operationResult.setDropdownMarkedCount(operationResult.getDropdownMarkedCount() + 1);
                        i++;
                        return;
                    } else if (!isSchemaDropdown && "true".equals(smap.get("multi"))) {//下拉框多选
                        List<String> multiValue = new ArrayList<>();
                        Collections.addAll(multiValue, value.split(";"));
                        List<String> settingList = Arrays.asList(smap.get(bizProperty.getCode()).split(";"));
                        boolean rm = multiValue.retainAll(settingList);
                        if (rm) {
                            map.put(bizProperty.getCode(), new CompMatchInfo<>(String.join(";", multiValue), true));
                            operationResult.setDropdownMarkedCount(operationResult.getDropdownMarkedCount() + 1);
                            return;
                        }
                    }
                }
                if (CollectionUtils.isNotEmpty(checkboxInfos.keySet()) && checkboxInfos.keySet().contains(bizProperty.getCode())) {
                    List<String> defaultInfors = new ArrayList<>();
                    Collections.addAll(defaultInfors, checkboxInfos.get(bizProperty.getCode()).split(";"));
                    List<String> valueInfors = new ArrayList<>();
                    Collections.addAll(valueInfors, value.split(";"));
                    boolean r = valueInfors.retainAll(defaultInfors);
                    //保持只有不匹配的才修改
                    if (r) {
                        map.put(bizProperty.getCode(), new CompMatchInfo<>(valueInfors.stream().collect(Collectors.joining(";")), true));
                        operationResult.setCheckboxMarkedCount(operationResult.getCheckboxMarkedCount() + 1);
                    } else {
                        map.put(bizProperty.getCode(), value);
                    }
                    //map.put(bizProperty.getCode(), valueTem.stream().collect(Collectors.joining(";")));
                    i++;
                    return;
                }
            }

            //主表
            if (isQueryData && StringUtils.isNotEmpty(value)) {
                String matchValue = validateShortTextData(bizFormModel, value, bizProperty);
                map.put(bizProperty.getCode(), matchValue);
                return;
            }
        }
        map.put(bizProperty.getCode(), value);
        i++;
    }

    //校验主表单选框，复选框，下拉单选，下拉多选是否匹配
    private String validateShortTextData(BizFormModel bizFormModel, String value, BizPropertyModel bizProperty) {
        String matchValue = value;
        String code = bizProperty.getCode();
        String publishedAttributesJsonStr = bizFormModel.getPublishedAttributesJson();
        JSONObject publishedAttributesJson = JSONObject.parseObject(publishedAttributesJsonStr);
        if (Objects.isNull(publishedAttributesJson)) {
            return matchValue;
        }
        CompProperty compProperty = JSON.parseObject(publishedAttributesJson.getString(code), CompProperty.class);
        //在数据项中存在，但在表单中不存在时
        if (Objects.isNull(compProperty)) {
            return matchValue;
        }
        Integer type = compProperty.getType();
        CompProperty.Option options1 = compProperty.getOptions();
        String options2 = options1.getOptions();
        //处理控件与配置不匹配的数据
        if ((type == BizFormPropertyType.RADIO.getIndex()
                || type == BizFormPropertyType.CHECKBOX.getIndex()
                || type == BizFormPropertyType.SELECT.getIndex())
                && StringUtils.isNotEmpty(options2)) {
            String regex = ";";
            String delimiter = ";";
            List<String> options2List = Arrays.asList(options2.split(regex));
            if (type == BizFormPropertyType.SELECT.getIndex()) {//下拉框
                boolean isSchemaDropdown = options2 != null && options2.contains("schemaCode")
                        && options2.contains("appCode") && options2.contains("sheetDataItem") && !options2.contains(";");
                if (!isSchemaDropdown && !options1.getMulti() && !options2List.contains(value)) {//下拉框单选
                    matchValue = null;
                } else if (!isSchemaDropdown && options1.getMulti()) {//下拉框多选
                    List<String> multiValue = new ArrayList<>();
                    Collections.addAll(multiValue, value.split(regex));
                    multiValue.retainAll(options2List);
                    matchValue = String.join(delimiter, multiValue);
                }
            } else if (type == BizFormPropertyType.RADIO.getIndex()) {//单选框
                if (!options2List.contains(value)) {
                    matchValue = null;
                }
            } else if (type == BizFormPropertyType.CHECKBOX.getIndex()) {//多选框
                List<String> ckList = new ArrayList<>();
                Collections.addAll(ckList, value.split(regex));
                if (ckList.retainAll(options2List)) {
                    matchValue = String.join(delimiter, ckList);
                }
            }
        }
        return matchValue;
    }


    //校验子表业务项短文本和系统数据项短文本
    private void checkChildShortText(List<String> defaultCodes, Map<String, Object> map, Object value
            , Boolean notEmpty, String name, List<ErrorValue> list, BizPropertyModel bizProperty
            , String childName, BizFormModel bizFormModel, String code) {

        //需要校验长度
        if (notEmpty && Objects.isNull(value)) {
            ErrorValue errorValue17 = new ErrorValue();
            errorValue17.setContent(childName + "-" + name + (notEmpty ? ",不能为空!" : ",可以为空!"));
            list.add(errorValue17);
            return;
        }
        String values = Objects.isNull(value) ? "" : value.toString();
        Integer maxLength = 200;
        if (!PropertyValidateHelper.validateShortText(values, maxLength, notEmpty)) {
            ErrorValue errorValue6 = new ErrorValue();
            errorValue6.setContent(childName + "-" + name + "：为短文本数据类型，内容太多，超出200个字符限制，请修改！");
            list.add(errorValue6);
            return;
        }
        //todo:测试和产品确认
        //系统数据项人或部门
        if (Objects.nonNull(value) && defaultCodes.contains(bizProperty.getCode())) {
            if (bizProperty.getCode().equals(DefaultPropertyType.SEQUENCE_STATUS.getCode())) {
                if (value.equals(WorkflowInstanceStatus.DRAFT.getName()) || value.equals(String.valueOf(WorkflowInstanceStatus.DRAFT.getIndex())) || value.equals(WorkflowInstanceStatus.DRAFT.name())) {
                    value = WorkflowInstanceStatus.DRAFT.name();
                    map.put(DefaultPropertyType.SEQUENCE_STATUS.getCode(), value);
                } else if (value.equals(WorkflowInstanceStatus.COMPLETED.getName()) || value.equals(String.valueOf(WorkflowInstanceStatus.COMPLETED.getIndex())) || value.equals(WorkflowInstanceStatus.COMPLETED.name())) {
                    value = WorkflowInstanceStatus.COMPLETED.name();
                    map.put(DefaultPropertyType.SEQUENCE_STATUS.getCode(), value);
                } else {
                    if (Objects.isNull(value)) {
                        value = WorkflowInstanceStatus.DRAFT.name();
                        map.put(DefaultPropertyType.SEQUENCE_STATUS.getCode(), value);
                    } else {
                        ErrorValue errorValue7 = new ErrorValue();
                        Object mapValue = (Objects.isNull(value)) ? "" : "-[" + value + "]";
                        errorValue7.setContent(childName + "-" + name + (notEmpty ? ",不能为空!" : ",可以为空!") + "内容格式错误" + mapValue + "," + "不支持数字填写，填写内容可为：草稿，已完成");
                        list.add(errorValue7);
                        return;
                    }
                }
            }
        } else {
            map.put(bizProperty.getCode(), value);

            //子表控件数据校验
            String publishedAttributesJsonStr = bizFormModel.getPublishedAttributesJson();
            JSONObject publishedAttributesJson = JSONObject.parseObject(publishedAttributesJsonStr);
            if (Objects.isNull(publishedAttributesJson)) {
                map.put(bizProperty.getCode(), value);
                return;
            }
            JSONObject childTable = publishedAttributesJson.getJSONObject(code);
            if (Objects.isNull(childTable)) {
                return;
            }
            JSONArray jsonArray = childTable.getJSONArray("columns");

            List<CompProperty> compProperties = JSONObject.parseArray(JSON.toJSONString(jsonArray), CompProperty.class);
            Optional<CompProperty> compPropertyOptional = compProperties.stream().filter(t -> t.getKey().equals(bizProperty.getCode())).findFirst();
            //在数据项中存在，表单中不存在时
            if (!compPropertyOptional.isPresent()) {
                map.put(bizProperty.getCode(), value);
                return;
            }
            CompProperty compProperty = compPropertyOptional.get();
            Integer type = compProperty.getType();
            CompProperty.Option options1 = compProperty.getOptions();
            String options2 = options1.getOptions();
            //处理控件与配置不匹配的数据
            if (type == 5 || type == 6 || type == 7) {
                if (StringUtils.isEmpty(options2)) {
                    map.put(bizProperty.getCode(), null);
                } else {
                    List<String> options2List = Arrays.asList(options2.split(";"));
                    if (type == 7) {//下拉框
                        boolean isSchemaDropdown = options2 != null && options2.contains("schemaCode")
                                && options2.contains("appCode") && options2.contains("sheetDataItem") && !options2.contains(";");
                        if (!isSchemaDropdown && !options1.getMulti() && !options2List.contains(values)) {//下拉框单选
                            map.put(bizProperty.getCode(), null);
                        } else if (!isSchemaDropdown && options1.getMulti()) {//下拉框多选
                            List<String> multiValue = new ArrayList<>();
                            Collections.addAll(multiValue, value.toString().split(";"));
                            multiValue.retainAll(options2List);
                            map.put(bizProperty.getCode(), String.join(";", multiValue));
                        }
                    } else if (type == 5) {//单选框
                        if (!options2List.contains(value)) {
                            map.put(bizProperty.getCode(), null);
                        }
                    } else if (type == 6) {//多选框
                        List<String> ckList = new ArrayList<>();
                        if (StringUtils.isBlank(values)) {
                            map.put(bizProperty.getCode(), null);
                            return;
                        }
                        Collections.addAll(ckList, value.toString().split(";"));
                        if (ckList.retainAll(options2List)) {
                            map.put(bizProperty.getCode(), String.join(";", ckList));
                        }
                    }
                    //class
                }//end else
                return;
            }

        }//
        map.put(bizProperty.getCode(), value);
    }


    // 校验子表导入的选人控件的数据格式
    private boolean checkFormSelection(Map<String, Object> params, Map<String, Object> map, String userId, String corpId, DepartmentModel rootDept, boolean success, OrgType orgType) {
        //参数拿出来
        int i = (int) params.get("i");
        List<String> editCodes = (List<String>) params.get("editCodes");
        BizPropertyModel bizProperty = (BizPropertyModel) params.get("bizProperty");
        String value = Objects.isNull(params.get("value")) ? "" : params.get("value").toString();
        //主表
        boolean isQueryData = true;
        //表单子表
        if (CollectionUtils.isNotEmpty(editCodes)) {
            isQueryData = false;
        }
        //为表单子表导入  /但是子表传入的数据项列表不包含  该编码
        if (!isQueryData && !editCodes.contains(bizProperty.getCode())) {
            map.put(bizProperty.getCode(), null);
            i++;
            return true;
        }
        String[] selections = value.split(";");
        //选人控件
        List<SelectionValue> selectionValues = new ArrayList<>();
        for (String selection : selections) {
            success = parseSelections(selection, rootDept, orgType, selectionValues, success, corpId);
        }
        map.put(bizProperty.getCode(), selectionValues);
        i++;
        return success;
    }

    private boolean parseUserSelections(String selection, List<SelectionValue> selectionValues, boolean success, String corpId, OrgType orgType) {
        String[] split = selection.split("\\.");
        //部门是否已经禁用
        boolean isDeptForbidden = false;
        List<UserModel> users = null;
        if (split.length < 2) {
            users = getOrganizationFacade().searchUsersByName(selection);
        }
        if (split.length == 2) {
            List<String> departmentIds = null;
            List<DepartmentModel> departmentModels = getOrganizationFacade().searchDepartmentByDepartmentName(split[1]);
            if (CollectionUtils.isNotEmpty(departmentModels)) {
                departmentIds = departmentModels.stream().filter(t -> !Objects.isNull(t) && Objects.equals(split[1], t.getName())).map(t -> t.getId()).collect(Collectors.toList());

                DepartmentModel departmentModel1 = departmentModels.stream().filter(departmentModel -> !departmentModel.getEnabled()).findFirst().orElse(null);
                isDeptForbidden = departmentModel1 != null;
            }
            if (CollectionUtils.isNotEmpty(departmentIds)) {
                users = getOrganizationFacade().searchUsersByNameAndDepartmentIds(split[0], departmentIds);
            }
        }
        if (CollectionUtils.isNotEmpty(users)) {
            users = users.stream().filter(userModel -> UserStatus.ENABLE == userModel.getStatus() && userModel.getName().equals(split[0])).collect(Collectors.toList());
            if (orgType != OrgType.MAIN && CollectionUtils.isNotEmpty(users)) {
                users = users.stream().filter(userModel -> Objects.equals(userModel.getCorpId(), corpId)).collect(Collectors.toList());
            }
        }

        SelectionValue selectionValue = new SelectionValue();
        if (isDeptForbidden) {
            parseSelectionValue(selectionValue, UnitType.USER, null, ExcelType.FORBIDDEN, split[0]);
            success = false;
            selectionValues.add(selectionValue);
        } else if (CollectionUtils.isEmpty(users) || users.size() < 1) {
            parseSelectionValue(selectionValue, UnitType.USER, null, ExcelType.NOEXIT, split[0]);
            success = false;
            selectionValues.add(selectionValue);
        } else if (users.size() > 1) {
            parseSelectionValue(selectionValue, UnitType.USER, null, ExcelType.REPEAT, split[0]);
            success = false;
            selectionValues.add(selectionValue);
        } else {
            parseSelectionValue(selectionValue, UnitType.USER, users.get(0).getId(), null, split[0]);
            selectionValues.add(selectionValue);
        }
        return success;
    }

    //校验导入的选人控件的数据格式
    private boolean checkSelection(List<String> defaultCodes, Map<String, Object> params, Map<String, Object> map, boolean success, String corpId, String userId, DepartmentModel rootDeptName, OrgType orgType) {
        //参数拿出来
        int i = (int) params.get("i");
        boolean notEmpty = (boolean) params.get("notEmpty");
        List<String> editCodes = (List<String>) params.get("editCodes");
        BizPropertyModel bizProperty = (BizPropertyModel) params.get("bizProperty");
        String value = Objects.isNull(params.get("value")) ? "" : params.get("value").toString();
        //主表
        boolean isQueryData = true;
        //子表
        if (CollectionUtils.isNotEmpty(editCodes)) {
            isQueryData = false;
        }
        if (StringUtils.isEmpty(value)) {
            if (notEmpty) {
                SelectionValue selectionValue = new SelectionValue();
                parseSelectionValue(selectionValue, UnitType.USER, null, ExcelType.EMPTY, null);
                success = false;
                map.put(bizProperty.getCode(), Lists.newArrayList(selectionValue));
                i++;
                return success;
            }
            map.put(bizProperty.getCode(), null);
            i++;
            return success;
        }
        //表单子表
        if (!isQueryData) {
            success = checkFormSelection(params, map, userId, corpId, rootDeptName, success, orgType);
            return success;
        } else {
            //列表主表
            //获取excel填写的值，多选之间设定是用英文分号符分隔
            String[] selections = value.split(";");
            //处理默认数据项选人控件
            if (defaultCodes.contains(bizProperty.getCode())) {
                List<SelectionValue> selectionValues = new ArrayList<>();
                success = parseSelections(selections[0], rootDeptName, orgType, selectionValues, success, corpId);
                i++;
                map.put(bizProperty.getCode(), selectionValues);
                return success;
            }
            //表单选人控件
            List<SelectionValue> selectionValues = new ArrayList<>();
            for (String selection : selections) {
                //封装下
                success = parseSelections(selection, rootDeptName, orgType, selectionValues, success, corpId);
            }
            map.put(bizProperty.getCode(), selectionValues);
            i++;
            return success;
        }
    }

    private void parseSelectionValue(SelectionValue selectionValue, UnitType unitType, String id, ExcelType excelType, String name) {
        selectionValue.setId(id);
        selectionValue.setName(name);
        selectionValue.setType(unitType);
        selectionValue.setExcelType(excelType);
    }

    private boolean parseSelections(String selection, DepartmentModel rootDeptName, OrgType orgType, List<SelectionValue> selectionValues, boolean success, String corpId) {
        List<String> departNames = StrUtil.splitTrim(selection, "/");
        log.debug("获取到的部门或者用户名称为{}", selection);
        //区分根节点和其他路径
        Map<String, String> mapDepart = new HashMap<>();
        boolean repeat = false;
        if (CollectionUtils.isNotEmpty(departNames)) {
            if (departNames.size() == 1) {
                String departName = departNames.get(0);
                boolean equals = Objects.equals(departName, rootDeptName.getName());
                if (equals) {
                    mapDepart.put(rootDeptName.getId(), departName);
                } else {
                    List<DepartmentModel> departmentModels = getOrganizationFacade().searchDepartmentByDepartmentName(departName, false);
                    if (CollectionUtils.isNotEmpty(departmentModels)) {
                        departmentModels = departmentModels.stream().filter(depart -> StringUtils.equals(depart.getName(), departName) && Boolean.TRUE.equals(depart.getEnabled())).collect(Collectors.toList());
                        if (departmentModels.size() > 1) {
                            repeat = true;
                        }
                        for (DepartmentModel departmentModel : departmentModels) {
                            if (departName.equals(departmentModel.getName())) {
                                mapDepart.put(departmentModel.getId(), departName);
                            }
                        }
                    }
                }
            } else {
                mapDepart = getOrganizationFacade().getParentDepartNames(departNames.get(departNames.size() - 1));
            }
        }
        if (MapUtils.isEmpty(mapDepart) || mapDepart.size() < 1) {
            success = parseUserSelections(selection, selectionValues, success, corpId, orgType);
        } else {
            boolean equals = false;
            for (String s : mapDepart.keySet()) {
                if (selection.equals(mapDepart.get(s))) {
                    DepartmentModel depart = getOrganizationFacade().getDepartment(s);
                    if (!Objects.equals(depart.getEnabled(), Boolean.TRUE)) {
                        continue;
                    }
                    SelectionValue selectionValue = new SelectionValue();
                    parseSelectionValue(selectionValue, UnitType.DEPARTMENT, depart.getId(), repeat ? ExcelType.REPEAT : null, depart.getName());
                    selectionValues.add(selectionValue);
                    equals = true;
                }
            }
            if (!equals) {
                SelectionValue selectionValue = new SelectionValue();
                parseSelectionValue(selectionValue, UnitType.DEPARTMENT, null, ExcelType.NOEXIT, selection);
                selectionValues.add(selectionValue);
                success = equals;
            }
        }
        return success;
    }

    //校验导入的子表选人控件的数据格式
    private boolean checkChildSelection(Map<String, Object> map, Object value, Boolean notEmpty, BizPropertyModel bizProperty,
                                        boolean ok, String corpId, DepartmentModel rootDept, OrgType orgType) {
        if (Objects.isNull(value)) {
            if (notEmpty) {
                ok = false;
                SelectionValue selectionValue = new SelectionValue();
                selectionValue.setId(null);
                selectionValue.setName(null);
                selectionValue.setType(UnitType.USER);
                selectionValue.setExcelType(ExcelType.EMPTY);
                selectionValue.setDepartmentId(null);
                selectionValue.setDepartments(Lists.newArrayList());
                selectionValue.setParentId(null);
                selectionValue.setImgUrl(null);
                map.put(bizProperty.getCode(), Lists.newArrayList(selectionValue));
                return ok;
            }
            map.put(bizProperty.getCode(), Lists.newArrayList());
            return ok;
        }
        String string = value.toString();
        String[] selections = string.split(";");
        //表单选人控件
        List<SelectionValue> selectionValues = new ArrayList<>();
        for (String selection : selections) {
            ok = parseSelections(selection, rootDept, orgType, selectionValues, ok, corpId);
        }
        map.put(bizProperty.getCode(), selectionValues);
        return ok;
    }

    private Map<String, String> parseAttribute(Map<String, List<String>> attrituteMaps, String key) {
        Map<String, String> mapInfos = new HashMap<>();
        if (CollectionUtils.isNotEmpty(attrituteMaps.get(key))) {
            for (String text : attrituteMaps.get(key)) {
                Map<String, String> map = (Map<String, String>) JSON.parse(text);
                for (String s : map.keySet()) {
                    mapInfos.put(s, map.get(s));
                }
            }
        }
        return mapInfos;
    }

    private Map<String, Map<String, String>> parseAttribute_dropdown(Map<String, List<String>> attrituteMaps, String key) {
        Map<String, Map<String, String>> mapInfos = new HashMap<>();
        if (CollectionUtils.isNotEmpty(attrituteMaps.get(key))) {
            for (String text : attrituteMaps.get(key)) {
                Map<String, Map<String, String>> map = (Map<String, Map<String, String>>) JSON.parse(text);
                //Map<String, String> map = (Map<String, String>) JSON.parse(text);
                for (String s : map.keySet()) {
                    mapInfos.put(s, map.get(s));
                }
            }
        }
        return mapInfos;
    }

    /**
     * 过滤出可删除的业务数据
     *
     */
    protected void disposeDeletePermissions(String userId, String schemaCode, List<String> ids, List<String> noDeleteIds) {
        AppFunctionModel appFunctionModel = getAppManagementFacade().getAppFunctionByCode(schemaCode);
        if (Objects.isNull(appFunctionModel)) {
            throw new PortalException(ErrCode.APP_FUNCTION_MODEL_NOTEXIST.getErrCode(), ErrCode.APP_FUNCTION_MODEL_NOTEXIST.getErrMsg());
        }
        boolean isAdmin;
        boolean isSysManager = false;
        boolean isDataManagerForApp = false;
        if ((isAdmin = isAdmin(userId))
                || (isSysManager = isSysManager(userId))
                || (isDataManagerForApp = isDataManagerForApp(userId, schemaCode))) {
            log.debug("admin={},sys_mng={},data_mng={}管理员有删除权限", isAdmin, isSysManager, isDataManagerForApp);
            return;
        }

        log.debug("处理普通用户对数据的删除权限");
        List<AppPackagePermissionModel> appPackagePermissionModels = getPermissionManagementFacade().getAppPackagePermissionsByUserId(userId);
        AppPackagePermissionModel appPackagePermissionModel = appPackagePermissionModels.stream().filter(t -> t.getAppPackage().getCode().equals(appFunctionModel.getAppCode()) && t.getAppPackage().getEnabled() && t.getVisibleType().equals(VisibleType.ALL_VISIABLE)).findAny().orElse(null);
        if (appPackagePermissionModel != null) {
            return;
        }
        List<PermissionGroupModel> permissionGroupModels = getPermissionManagementFacade().getPermissionGroupsByAppCodeAndUserId(appFunctionModel.getAppCode(), userId);
        if (CollectionUtils.isEmpty(permissionGroupModels)) {
            return;
        }
        List<AppFunctionPermissionModel> appFunctionPermissionModels = new ArrayList<>();
        for (PermissionGroupModel permissionGroupModel : permissionGroupModels) {
            List<AppFunctionPermissionModel> appFunctionPermissionModelTemplates = permissionGroupModel.getDataPermissionGroups();
            if (CollectionUtils.isNotEmpty(appFunctionPermissionModelTemplates)) {
                AppFunctionPermissionModel appFunctionPermission = appFunctionPermissionModelTemplates.stream().filter(t -> t.getVisible() && t.getSchemaCode().equals(schemaCode) && t.getDeletable()).findAny().orElse(null);
                if (appFunctionPermission != null) {
                    if (appFunctionPermission.getDataPermissionType().equals(DataPermissionType.CUSTOM)) {
                        appFunctionPermission.setConditions(getPermissionManagementFacade().getAppFunctionPermissionConditions(schemaCode));
                    }
                    appFunctionPermissionModels.add(appFunctionPermission);
                }
            }
        }
        if (CollectionUtils.isEmpty(appFunctionPermissionModels)) {
            log.debug("没有配置删除权限无法删除数据");
            ids.clear();
            return;
        }
        List<WorkflowInstanceModel> workflowInstances = getWorkflowInstanceFacade().getWorkflowInstancesByBizObjectId(ids);
        List<String> idsForSheet = workflowInstances.stream().map(WorkflowInstanceModel::getBizObjectId).collect(Collectors.toList());
        if (CollectionUtils.isNotEmpty(workflowInstances)) {
            log.debug("流程表单数据为{}", idsForSheet);
            workflowInstances.forEach(workflowInstanceModel -> {
                //发起人可以删除草稿状态的数据
                if (workflowInstanceModel.getState() == WorkflowInstanceStatus.DRAFT && userId.equals(workflowInstanceModel.getOriginator())) {
                    idsForSheet.remove(workflowInstanceModel.getBizObjectId());
                }
            });
            noDeleteIds.addAll(idsForSheet);
            ids.removeAll(idsForSheet);
        }
    }

    /**
     * 获取查询条件对象
     *
     * @param userId
     * @param queryDataVO   查询数据结果
     * @param bizQueryModel 列表详细信息
     * @return BizObjectQueryModel
     */
    /**
     * @param userId        用户id
     * @param queryDataVO   查询数据结果
     * @param bizQueryModel 列表详细信息
     * @param isAuthFilter  是否权限查询
     * @param isOwner       拥有者修改时调用查找权限时用的字段
     * @returnBizObjectQueryModel
     */
    protected BizObjectQueryModel getBizObjectQuerys(String userId, QueryDataVO queryDataVO, BizQueryModel bizQueryModel, Boolean isAuthFilter, Boolean isOwner) {
        List<FilterExpression> filterExprs = new ArrayList<>();
        //权限条件
        FilterExpression authFilter = FilterExpression.empty;
        if (isAuthFilter) {

            //是否临时授权
            if (StringUtils.isNotEmpty(queryDataVO.getTempAuthObjectId()) || StringUtils.isNotEmpty(queryDataVO.getTempAuthPropertyCode())) {
                BizFormModel sourceSheet = getBizObjectFacade().getTempAuthSchemaCodes(queryDataVO.getTempAuthSheetId());
                if (sourceSheet == null) {
                    authFilter = getAuthFilters(userId, queryDataVO.getSchemaCode(), isOwner);
                } else {
                    //跳转过来的源表单的临时授权当前访问的表单  与前端约定保存的表单数据为 SchemaCode_SheetCode
                    if (sourceSheet.getTempAuthSchemaCodes().contains(bizQueryModel.getSchemaCode() + "_")) {
                        authFilter = getAuthFilters(userId, sourceSheet.getSchemaCode(), isOwner);
                    } else {
                        authFilter = getAuthFilters(userId, queryDataVO.getSchemaCode(), isOwner);
                    }
                }
            } else {
                authFilter = getAuthFilters(userId, queryDataVO.getSchemaCode(), isOwner);
            }
        }
        //生成查询条件
        FilterExpression finalFilterExpr = getFilterList(queryDataVO.getFilters(), bizQueryModel.getQueryConditions(), queryDataVO.isCustomizedQuery());

        //生成选中的列表的查询条件
        FilterExpression checkedFilter = getCheckedFilters(queryDataVO.getObjectIds());

        if (!Objects.equals(authFilter, FilterExpression.empty)) {
            filterExprs.add(authFilter);
        }
        if (!finalFilterExpr.equals(FilterExpression.empty)) {
            filterExprs.add(finalFilterExpr);
        }
        if (!checkedFilter.equals(FilterExpression.empty)) {
            filterExprs.add(checkedFilter);
        }
        this.filterSeqStatus(userId, filterExprs);

        BizObjectQueryModel bizObjectQueryObject = new BizObjectQueryModel();
        FilterExpression filterExprTemplate = FilterExpression.empty;
        if (filterExprs.size() > 1) {
            filterExprTemplate = Q.and(filterExprs);
            if (log.isDebugEnabled()) {
                log.debug("获取的权限相关条件为{}", JSON.toJSONString(filterExprTemplate));
            }
        } else if (filterExprs.size() == 1) {
            filterExprTemplate = filterExprs.get(0);
            if (log.isDebugEnabled()) {
                log.debug("获取的权限相关条件为{}", JSON.toJSONString(filterExprTemplate));
            }
        }

        bizObjectQueryObject.setFilterExpr(filterExprTemplate);
        bizObjectQueryObject.setSchemaCode(bizQueryModel.getSchemaCode());
        bizObjectQueryObject.setClientType(Objects.nonNull(queryDataVO.getMobile()) && queryDataVO.getMobile() ? ClientType.APP : ClientType.PC);
        return bizObjectQueryObject;
    }

    /**
     * 获取关联查询/反关联查询条件对象
     *
     * @param userId        用户id
     * @param queryDataVO   查询数据结果
     * @param bizQueryModel 列表详细信息
     * @return BizObjectQueryModel
     */
    protected BizObjectQueryModel getBizObjectQuery(String userId, QueryDataVO queryDataVO, BizQueryModel bizQueryModel, Boolean isAuthFilter, Boolean isOwner) {
        List<FilterExpression> filterExprs = new ArrayList<>();
        //权限条件
        FilterExpression authFilter = FilterExpression.empty;
        if (isAuthFilter) {
            authFilter = getAuthFilters(userId, queryDataVO.getSchemaCode(), isOwner);
        }
        //生成查询条件
        FilterExpression finalFilterExpr = getFilters(queryDataVO.getFilters(), bizQueryModel.getQueryConditions());

        //生成选中的列表的查询条件
        FilterExpression checkedFilter = getCheckedFilters(queryDataVO.getObjectIds());
        if (!authFilter.equals(FilterExpression.empty)) {
            filterExprs.add(authFilter);
        }
        if (!finalFilterExpr.equals(FilterExpression.empty)) {
            filterExprs.add(finalFilterExpr);
        }
        if (!checkedFilter.equals(FilterExpression.empty)) {
            filterExprs.add(checkedFilter);
        }

        //有流程的数据排除模拟流程的数据 SIMULATIVE；没有流程的保留 workflowInstanceId 为空
        List<String> simulatives = getWorkflowInstanceFacade().findIdListBySchemaCodeAndDataType(queryDataVO.getSchemaCode(), ProcessDataType.SIMULATIVE);
        if (!CollectionUtil.isEmpty(simulatives)) {
            FilterExpression.Or or = Q.or(Q.it(DefaultPropertyType.WORKFLOW_INSTANCE_ID.getCode(), FilterExpression.Op.NotIn, simulatives),
                    Q.it(DefaultPropertyType.WORKFLOW_INSTANCE_ID.getCode(), FilterExpression.Op.Eq, null));
            filterExprs.add(or);
        }
        this.filterSeqStatus(userId, filterExprs);

        BizObjectQueryModel bizObjectQueryObject = new BizObjectQueryModel();
        FilterExpression filterExprTemplate = FilterExpression.empty;
        if (filterExprs.size() > 1) {
            filterExprTemplate = Q.and(filterExprs);
            if (log.isDebugEnabled()) {
                log.debug("获取的权限相关条件为{}", JSON.toJSONString(filterExprTemplate));
            }
        } else if (filterExprs.size() == 1) {
            filterExprTemplate = filterExprs.get(0);
            if (log.isDebugEnabled()) {
                log.debug("获取的权限相关条件为{}", JSON.toJSONString(filterExprTemplate));
            }
        }

        bizObjectQueryObject.setFilterExpr(filterExprTemplate);
        bizObjectQueryObject.setSchemaCode(bizQueryModel.getSchemaCode());
        bizObjectQueryObject.setClientType(Objects.nonNull(queryDataVO.getMobile()) && queryDataVO.getMobile() ? ClientType.APP : ClientType.PC);
        return bizObjectQueryObject;
    }

    /**
     * 不能查看不是自己的草稿
     *
     * @param userId
     * @param filterExprs
     */
    private void filterSeqStatus(String userId, List<FilterExpression> filterExprs) {
        FilterExpression.And eqDraft = Q.and(Q.it(DefaultPropertyType.CREATER.getCode(), FilterExpression.Op.Eq, userId),
                Q.it(DefaultPropertyType.SEQUENCE_STATUS.getCode(), FilterExpression.Op.Eq, WorkflowInstanceStatus.DRAFT.toString()));
        FilterExpression.Or or = Q.or(eqDraft,
                Q.it(DefaultPropertyType.SEQUENCE_STATUS.getCode(), FilterExpression.Op.NotEq, WorkflowInstanceStatus.DRAFT.toString()));
        filterExprs.add(or);
    }


    private FilterExpression getFilterList(List<FilterVO> filterList, List<BizQueryConditionModel> queryConditions, boolean customizedQuery) {
        if (CollectionUtils.isEmpty(queryConditions) && CollectionUtils.isEmpty(filterList)) {
            return FilterExpression.empty;
        }
        List<FilterExpression> filters = new ArrayList<>();
        //需要处理的可见条件
        List<BizQueryConditionModel> visibleCondition = null;
        //需要处理的隐藏条件=
        List<BizQueryConditionModel> hiddenCondition = null;
        if (CollectionUtils.isNotEmpty(queryConditions)) {
            visibleCondition = queryConditions.stream().filter(condition -> condition.getVisible()).collect(Collectors.toList());
            hiddenCondition = queryConditions.stream().filter(condition -> !condition.getVisible()).collect(Collectors.toList());
        }

        if (!customizedQuery) {
            //生成可见适配条件
            if (CollectionUtils.isNotEmpty(filterList)) {
                if (CollectionUtils.isNotEmpty(visibleCondition)) {
                    createVisibleFilters(filterList, visibleCondition, filters);
                }
                if (CollectionUtils.isNotEmpty(hiddenCondition)) {
                    createHiddenFilter(filterList, hiddenCondition, filters);
                }
            }

            //可见和隐藏适配条件的编码
            List<String> codeList = new ArrayList<>();
            if (CollectionUtils.isNotEmpty(visibleCondition)) {
                List<String> propertyCodeList = visibleCondition.stream().map(BizQueryConditionModel::getPropertyCode).collect(Collectors.toList());
                codeList.addAll(propertyCodeList);
            }
            if (CollectionUtils.isNotEmpty(hiddenCondition)) {
                List<String> propertyCodeList = hiddenCondition.stream().map(BizQueryConditionModel::getPropertyCode).collect(Collectors.toList());
                codeList.addAll(propertyCodeList);
            }

            for (FilterVO filterVO : filterList) {
                if (filterVO.getOperatorType() != null) {
                    FilterExpression.Op op = FilterExpression.Op.Like;
                    switch (filterVO.getOperatorType()) {
                        case NEQ:
                        case IS_NOT_NULL:
                            op = FilterExpression.Op.NotEq;
                            break;
                        case GT:
                            op = FilterExpression.Op.Gt;
                            break;
                        case IT:
                            op = FilterExpression.Op.Lt;
                            break;
                        case GTEQ:
                            op = FilterExpression.Op.Gte;
                            break;
                        case ITEQ:
                            op = FilterExpression.Op.Lte;
                            break;
                        case NOT_OF:
                        case NOT_HAVE:
                        case NOT_IN:
                        case NOT_CONTAINS:
                            op = FilterExpression.Op.NotLike;
                            break;
                        case IS_NULL:
                        case EQ:
                            op = FilterExpression.Op.Eq;
                            break;
                        case HAVE:
                        case IN:
                        case CONTAINS:
                        case OF:
                            op = FilterExpression.Op.Like;
                            break;
                        default:
                    }
                    if (filterVO.getPropertyType() == BizPropertyType.ADDRESS) {
                        setAddressPropertyFilter(filters, filterVO, filterVO.getPropertyCode());
                    } else if (filterVO.getPropertyType().equals(BizPropertyType.SELECTION)) {
                        FilterExpression.Item item = null;
                        List<String> value = filterVO.getPropertyValue();
                        if (CollectionUtils.isNotEmpty(value)) {
                            FilterExpression.Item items = Q.it(filterVO.getPropertyCode(), op, value);
                            filters.add(items);
                        } else {
                            FilterExpression.Item items = Q.it(filterVO.getPropertyCode(), op, value);
                            filters.add(items);
                        }
                    } else if (filterVO.getPropertyType().equals(BizPropertyType.LOGICAL)) {
                        FilterExpression.Item item = Q.it(filterVO.getPropertyCode(), op, filterVO.getPropertyValue().get(0));
                        filters.add(item);
                    } else {
                        List<String> propertyValue = filterVO.getPropertyValue();
                        if (CollectionUtils.isNotEmpty(propertyValue) && null != filterVO.getOperatorType()) {
                            for (String s : propertyValue) {
                                FilterExpression.Item items = Q.it(filterVO.getPropertyCode(), op, s);
                                filters.add(items);
                            }
                        } else {
                            FilterExpression.Item items = Q.it(filterVO.getPropertyCode(), op, "");
                            filters.add(items);
                        }
                    }
                    continue;
                }

                if (DefaultPropertyType.SEQUENCE_STATUS.getCode().equals(filterVO.getPropertyCode())) {
                    if (CollectionUtils.isEmpty(filterVO.getPropertyValue())) {
                        continue;
                    }
                    FilterExpression.Item items = Q.it(filterVO.getPropertyCode(), FilterExpression.Op.In, filterVO.getPropertyValue());
                    filters.add(items);
                }
                //查询信息是否是配置条件，如果是就无需再操作
                if (CollectionUtils.isEmpty(filterVO.getPropertyValue()) || StringUtils.isBlank(StringUtils.strip(filterVO.getPropertyValue().toString(), "[]"))) {
                    continue;
                }
                if (CollectionUtils.isNotEmpty(codeList)) {
                    if (codeList.contains(filterVO.getPropertyCode())) {
                        continue;
                    }
                    FilterExpression.Item items = Q.it(filterVO.getPropertyCode(), FilterExpression.Op.Like, filterVO.getPropertyValue());
                    filters.add(items);
                } else {
                    FilterExpression.Item items = Q.it(filterVO.getPropertyCode(), FilterExpression.Op.Like, filterVO.getPropertyValue());
                    filters.add(items);
                }
            }
        } else {
            for (FilterVO filterVO : filterList) {
                FilterExpression.Op op = FilterExpression.Op.Like;
                if (filterVO.getOp() != null) {
                    switch (filterVO.getOp()) {
                        case Eq:
                            op = FilterExpression.Op.Eq;
                            break;
                        case NotEq:
                            op = FilterExpression.Op.NotEq;
                            break;
                        case Like:
                            op = FilterExpression.Op.Like;
                            break;
                        case NotLike:
                            op = FilterExpression.Op.NotLike;
                            break;
                        case Gt:
                            op = FilterExpression.Op.Gt;
                            break;
                        case Lt:
                            op = FilterExpression.Op.Lt;
                            break;
                    }
                }
                if (filterVO.getPropertyType() == BizPropertyType.ADDRESS) {
                    setAddressPropertyFilter(filters, filterVO, filterVO.getPropertyCode());
                } else {
                    List<String> propertyValue = filterVO.getPropertyValue();
                    if (CollectionUtils.isNotEmpty(propertyValue)) {
                        for (String s : propertyValue) {
                            FilterExpression.Item items = Q.it(filterVO.getPropertyCode(), op, s);
                            filters.add(items);
                        }
                    } else {
                        FilterExpression.Item items = Q.it(filterVO.getPropertyCode(), op, null);
                        filters.add(items);
                    }
                }
            }
        }

        if (CollectionUtils.isEmpty(filters)) {
            return FilterExpression.empty;
        }
        if (filters.size() == 1) {
            return filters.get(0);
        }
        return Q.and(filters);
    }


    /**
     * 关联查询和反关联生成查询条件
     *
     * @param filterList      查询条件
     * @param queryConditions 查询条件
     * @return FilterExpr
     */
    private FilterExpression getFilters(List<FilterVO> filterList, List<BizQueryConditionModel> queryConditions) {
        if (CollectionUtils.isEmpty(queryConditions) && CollectionUtils.isEmpty(filterList)) {
            return FilterExpression.empty;
        }
        List<FilterExpression> filters = new ArrayList<>();
        //需要处理的可见条件
        List<BizQueryConditionModel> visibleCondition = null;
        //需要处理的隐藏条件=
        List<BizQueryConditionModel> hiddenCondition = null;
        if (CollectionUtils.isNotEmpty(queryConditions)) {
            visibleCondition = queryConditions.stream().filter(condition -> condition.getVisible()).collect(Collectors.toList());
            hiddenCondition = queryConditions.stream().filter(condition -> !condition.getVisible()).collect(Collectors.toList());
        }

        //生成可见适配条件
        if (CollectionUtils.isNotEmpty(filterList)) {
            if (CollectionUtils.isEmpty(visibleCondition) && CollectionUtils.isEmpty(hiddenCondition)) {
                createVisibleFilter(filterList, visibleCondition, filters);
            } else {
                if (CollectionUtils.isNotEmpty(visibleCondition)) {
                    createVisibleFilter(filterList, visibleCondition, filters);
                }
                if (CollectionUtils.isNotEmpty(hiddenCondition)) {
                    createHiddenFilter(filterList, hiddenCondition, filters);
                }
            }
        }
        if (CollectionUtils.isEmpty(filters)) {
            return FilterExpression.empty;
        }
        if (filters.size() == 1) {
            return filters.get(0);
        }
        return Q.and(filters);
    }

    /**
     * 根据选项构建正则表达式查询条件
     *
     * @param propertyValue
     * @return
     */
    private String generateRegex(List<String> propertyValue) {
        StringBuilder sb = new StringBuilder();
        for (String value : propertyValue) {
            sb.append("(").append(value).append(")");
        }
        return String.format(DEFAULT_REGEX, sb.toString(), propertyValue.size() - 1, sb.toString());
    }

    /**
     * 排列组合的结果集
     *
     * @param value
     * @return
     */
    public List<String> getPropertyValue(List<String> value) {

        List<String> result = new ArrayList<>();
        for (int i = 0; i < value.size(); i++) {
            List<String> medium = new ArrayList<>();
            arrangementSort(value, Arrays.asList(new String[i + 1]), 0, medium);
            result.addAll(medium);
        }
        return result;
    }

    /**
     * 通过递归的方式罗列出所有的排列结果
     *
     * @param value：初始数组
     * @param init：排列数组初始状态
     * @param resultIndex：比较的起始索引
     */
    public static void arrangementSort(List<String> value, List<String> init, int resultIndex, List<String> medium) {
        int result_length = init.size();
        if (resultIndex >= result_length) {
            if (init.size() > 1) {
                String join = Joiner.on(";").skipNulls().join(init);
                medium.add(join);
            } else {
                medium.addAll(init);
            }
            return;
        }
        for (int i = 0; i < value.size(); i++) {
            // 判断待选的数是否存在于排列的结果中
            boolean exist = false;
            for (int j = 0; j < resultIndex; j++) {
                if (Objects.equals(value.get(i), init.get(j))) {  // 若已存在，则不能重复选
                    exist = true;
                    break;
                }
            }
            if (!exist) {  // 若不存在，则可以选择
                String s = value.get(i);
                init.set(resultIndex, s);
                arrangementSort(value, init, resultIndex + 1, medium);
            }
        }
    }

    /**
     * 生成隐藏过滤条件
     *
     * @param hiddenCondition 查询条件
     * @param filters         过滤
     */
    private void createHiddenFilter(List<FilterVO> filterVOs, List<BizQueryConditionModel> hiddenCondition, List<FilterExpression> filters) {
        //如果表单配置的过滤条件无在这里过滤
        filterVOs = filterVOs.stream().filter(filterVO -> Objects.isNull(filterVO.getOperatorType())).collect(Collectors.toList());
        for (BizQueryConditionModel condition : hiddenCondition) {
            //oracle数据库下 默认值为null，生成过滤条件异常。
            String defaultValue = StringUtils.isBlank(condition.getDefaultValue()) ? "" : condition.getDefaultValue();
            List<String> properValue = Arrays.asList(defaultValue.split(";"));
            FilterExpression.Item item = null;
            if (condition.getPropertyType().equals(BizPropertyType.SELECTION)) {
                filterVOs = filterVOs.stream().filter(t -> Objects.equals(t.getPropertyType(), BizPropertyType.SELECTION)).collect(Collectors.toList());

                List<String> idsP = Lists.newArrayList();
                List<String> idsDpt = Lists.newArrayList();
                List<String> idsSelection = Lists.newArrayList();
                filterVOs.forEach(t -> {
                    List<String> values = t.getPropertyValue();
                    if (CollectionUtils.isEmpty(values)) {
                        return;
                    }
                    if (Objects.equals(t.getPropertyCode(), DefaultPropertyType.CREATER.getCode()) || Objects.equals(t.getPropertyCode(), DefaultPropertyType.OWNER.getCode())) {
                        idsP.addAll(values);
                    } else if (Objects.equals(t.getPropertyCode(), DefaultPropertyType.CREATED_DEPT_ID.getCode()) || Objects.equals(t.getPropertyCode(), DefaultPropertyType.OWNER_DEPT_ID.getCode())) {
                        idsDpt.addAll(values);
                    }
                    if (CollectionUtils.isNotEmpty(values)) {
                        idsSelection.addAll(values);
                    }
                });
                List<String> defaults = Lists.newArrayList();
                if(CollectionUtils.isNotEmpty(filterVOs)){
                    FilterVO filterVO = filterVOs.get(0);
                    if(Objects.nonNull(filterVO)){
                        defaults.addAll(filterVO.getDefaultProperties());
                    }
                }
                if (Objects.equals(condition.getDefaultValue(), "1")) {
                    //本人
                    if (defaults.contains(condition.getPropertyCode())) {
                        item = Q.it(condition.getPropertyCode(), FilterExpression.Op.In, idsP);
                        if (CollectionUtils.isNotEmpty(idsP)) {
                            filters.add(item);
                        }
                    } else {
                        List<FilterExpression> items = Lists.newArrayList();
                        if (CollectionUtils.isNotEmpty(idsSelection)) {
                            for (String id : idsSelection) {
                                items.add(Q.it(condition.getPropertyCode(), FilterExpression.Op.Like, id));
                            }
                            if (items.size() == 1) {
                                filters.add(items.get(0));
                            } else {
                                filters.add(Q.or(items));
                            }
                        }
                    }
                } else if (Objects.equals(condition.getDefaultValue(), "2")) {
                    //本部门
                    if (defaults.contains(condition.getPropertyCode())) {
                        item = Q.it(condition.getPropertyCode(), FilterExpression.Op.In, idsDpt);
                        if (CollectionUtils.isNotEmpty(idsDpt)) {
                            filters.add(item);
                        }
                    } else {
                        List<FilterExpression> items = Lists.newArrayList();
                        for (String id : idsSelection) {
                            items.add(Q.it(condition.getPropertyCode(), FilterExpression.Op.Like, id));
                        }
                        //对条件判空
                        if (CollectionUtils.isNotEmpty(items)) {
                            if (items.size() == 1) {
                                filters.add(items.get(0));
                            } else {
                                filters.add(Q.or(items));
                            }
                        }
                    }
                }
                continue;
            }

            if (condition.getDisplayType() != null && condition.getDisplayType().equals(DisplayType.CHECKBOX)) {
                item = Q.it(condition.getPropertyCode(), FilterExpression.Op.In, properValue);
                if (CollectionUtils.isNotEmpty(properValue)) {
                    filters.add(item);
                }
                continue;
            }
            if (condition.getDisplayType() != null && condition.getDisplayType().equals(DisplayType.SELECT)) {
                //多选精确查询

                if (CollectionUtils.isNotEmpty(properValue) && properValue.size() > 1) {
                    String regex = generateRegex(properValue);
                    FilterExpression.Item it = Q.it(condition.getPropertyCode(), FilterExpression.Op.Reg, regex);
                    filters.add(it);
                    continue;
                } else if (CollectionUtils.isEmpty(properValue)) {
                    continue;
                } else if (CollectionUtils.isNotEmpty(properValue) && properValue.size() == 1) {
                    String s = properValue.get(0);
                    if (StringUtils.isEmpty(s)) {
                        continue;
                    }
                    item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Eq, properValue);
                    filters.add(item);
                    continue;
                }
            }
            if (condition.getDisplayType() != null && condition.getDisplayType().equals(DisplayType.RANGE) || condition.getPropertyType().equals(BizPropertyType.NUMERICAL) || condition.getPropertyType().equals(BizPropertyType.DATE)) {
                //拿到传入的条件
                FilterVO filter = null;
                if (CollectionUtils.isNotEmpty(filterVOs)) {
                    List<FilterVO> collect = filterVOs.stream().filter(filterVO -> Objects.equals(filterVO.getPropertyCode(), condition.getPropertyCode())).collect(Collectors.toList());
                    if (CollectionUtils.isNotEmpty(collect)) {
                        filter = collect.get(0);
                    }
                }
                createScopeFilter(condition, filter, filters, Boolean.TRUE);
                continue;
            }
            if (condition.getDisplayType() != null && condition.getDisplayType().equals(DisplayType.INPUT)) {
                if (condition.getPropertyType() == BizPropertyType.ADDRESS) {
                    List<FilterVO> collect = filterVOs.stream().filter(f -> condition.getPropertyCode().equals(f.getPropertyCode())).collect(Collectors.toList());
                    if (CollectionUtils.isNotEmpty(collect) && CollectionUtils.isNotEmpty(collect.get(0).getPropertyValue())) {
                        String address = collect.get(0).getPropertyValue().get(0);
                        Map<String, String> addressMap = JSON.parseObject(address, new TypeReference<Map<String, String>>() {
                        });
                        String provinceAdcode = addressMap.get("provinceAdcode");
                        String cityAdcode = addressMap.get("cityAdcode");
                        String districtAdcode = addressMap.get("districtName");
                        if (StringUtils.isNotEmpty(provinceAdcode)) {
                            item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Like, provinceAdcode);
                            filters.add(item);
                        }
                        if (StringUtils.isNotEmpty(cityAdcode)) {
                            item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Like, cityAdcode);
                            filters.add(item);
                        }
                        if (StringUtils.isNotEmpty(districtAdcode)) {
                            item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Like, districtAdcode);
                            filters.add(item);
                        }
                    }
                } else if (condition.getPropertyType() == BizPropertyType.LOGICAL) {
                    List<FilterVO> collect = filterVOs.stream().filter(f -> condition.getPropertyCode().equals(f.getPropertyCode())).collect(Collectors.toList());
                    if (CollectionUtils.isNotEmpty(collect) && CollectionUtils.isNotEmpty(collect.get(0).getPropertyValue())) {
                        String logic = collect.get(0).getPropertyValue().get(0);
                        if (StringUtils.isNotEmpty(logic)) {
                            item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Eq, logic);
                            filters.add(item);
                        }
                    }
                } else {
                    List<FilterVO> collect = filterVOs.stream().filter(filterVO -> Objects.equals(filterVO.getPropertyCode().toString(), condition.getPropertyCode().toString())).collect(Collectors.toList());
                    if (CollectionUtils.isNotEmpty(collect)) {
                        List<String> propertyValue = collect.get(0).getPropertyValue();
                        if (CollectionUtils.isNotEmpty(propertyValue)) {
                            String s = collect.get(0).getPropertyValue().get(0);
                            if (StringUtils.isNotEmpty(s)) {
                                item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Like, s);
                                filters.add(item);
                            }
                        }
                    }

                }
                continue;
            }
            List<FilterVO> collect = filterVOs.stream().filter(filterVO -> Objects.equals(filterVO.getPropertyCode(), condition.getPropertyCode())).collect(Collectors.toList());
            item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Eq, collect.get(0).getPropertyValue().get(0));
            filters.add(item);
            continue;
        }

    }

    private void createVisibleFilters(List<FilterVO> filterVOs, List<BizQueryConditionModel> visibleCondition, List<FilterExpression> filters) {
        //如果表单配置的过滤条件无在这里过滤
        filterVOs = filterVOs.stream().filter(filterVO -> Objects.isNull(filterVO.getOperatorType())).collect(Collectors.toList());
        for (FilterVO filterVO : filterVOs) {
            boolean machAble = false;
            if (BizPropertyType.WORK_SHEET.equals(filterVO.getPropertyType())) {
                if (CollectionUtils.isEmpty(filterVO.getPropertyValue())) {
                    continue;
                }
                FilterExpression.Item items = Q.it(filterVO.getPropertyCode(), FilterExpression.Op.Eq, filterVO.getPropertyValue().get(0));
                filters.add(items);
            }
            if (CollectionUtils.isNotEmpty(visibleCondition)) {
                for (BizQueryConditionModel condition : visibleCondition) {
                    FilterExpression.Item item = null;
                    if (filterVO.getPropertyCode().equals(condition.getPropertyCode())) {
                        machAble = true;
                        if (CollectionUtils.isEmpty(filterVO.getPropertyValue())) {
                            continue;
                        }
                        if (condition.getPropertyType().equals(BizPropertyType.SELECTION)) {
                            List<String> defaults = filterVO.getDefaultProperties();
                            if (defaults.contains(filterVO.getPropertyCode()) &&
                                    (DefaultPropertyType.OWNER_DEPT_ID.getCode().equals(filterVO.getPropertyCode()) ||
                                            DefaultPropertyType.CREATED_DEPT_ID.getCode().equals(filterVO.getPropertyCode()))) {
                                //创建人部门过滤权限
                                List<String> departmentIds = Lists.newArrayList();
                                for (String deptId : filterVO.getPropertyValue()) {
                                    List<String> deptIds = Lists.newArrayList();
                                    departmentIds.add(deptId);
                                    List<DepartmentModel> departmentModels = getOrganizationFacade().getDepartmentsChildList(departmentIds, true);
                                    if (CollectionUtils.isNotEmpty(departmentModels)) {
                                        departmentModels.stream().forEach(departmentModel -> {
                                            deptIds.add(departmentModel.getId());
                                        });
                                        deptIds.add(deptId);
                                        departmentIds.addAll(deptIds);
                                    } else {
                                        departmentIds.add(deptId);
                                    }
                                }
                                item = Q.it(condition.getPropertyCode(), FilterExpression.Op.In, departmentIds);
                                if (CollectionUtils.isNotEmpty(departmentIds)) {
                                    filters.add(item);
                                }
                                break;
                            }

                            if (defaults.contains(filterVO.getPropertyCode())) {
                                item = Q.it(condition.getPropertyCode(), FilterExpression.Op.In, filterVO.getPropertyValue());
                                if (CollectionUtils.isNotEmpty(filterVO.getPropertyValue())) {
                                    filters.add(item);
                                }
                                break;
                            }
                            List<FilterExpression> filterTemplates = new ArrayList<>();
                            for (String s : filterVO.getPropertyValue()) {
                                filterTemplates.add(Q.it(filterVO.getPropertyCode(), FilterExpression.Op.Like, s));
                            }
                            if (CollectionUtils.isNotEmpty(filterTemplates)) {
                                if (filterTemplates.size() == 1) {
                                    filters.add(filterTemplates.get(0));
                                } else {
                                    filters.add(Q.or(filterTemplates));
                                }
                            }
                            break;
                        }
                        if (condition.getDisplayType() != null && condition.getDisplayType().equals(DisplayType.CHECKBOX)) {
                            item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Like, filterVO.getPropertyValue());
                            filters.add(item);
                            break;
                        }
                        if (condition.getDisplayType() != null && condition.getDisplayType().equals(DisplayType.SELECT)) {
                            //修改  多选精确查询
                            List<String> propertyValue = filterVO.getPropertyValue();
                            if (CollectionUtils.isNotEmpty(propertyValue) && propertyValue.size() > 1) {
                                String regex = generateRegex(propertyValue);
                                FilterExpression.Item it = Q.it(condition.getPropertyCode(), FilterExpression.Op.Reg, regex);
                                filters.add(it);
                                break;
                            }
                            //修改 修改  多选精确查询
                            item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Eq, filterVO.getPropertyValue());
                            filters.add(item);
                            break;
                        }
                        if (condition.getDisplayType() != null && condition.getDisplayType().equals(DisplayType.RANGE) || condition.getPropertyType().equals(BizPropertyType.NUMERICAL) || condition.getPropertyType().equals(BizPropertyType.DATE)) {
                            createScopeFilter(condition, filterVO, filters, false);
                            break;
                        }
                        if (condition.getPropertyType().equals(BizPropertyType.LOGICAL)) {
                            item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Eq, filterVO.getPropertyValue().get(0));
                            filters.add(item);
                            break;
                        }
                        if (condition.getDisplayType() != null && condition.getDisplayType().equals(DisplayType.INPUT)) {
                            /*
                             * 地址控件类型查询条件，根据编码查询
                             * 格式:
                             *    省
                             *    省-市
                             *    省-市-区
                             */
                            setAddressPropertyFilter(filters, filterVO, condition.getPropertyCode());
                            break;
                        }
                        item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Eq, filterVO.getPropertyValue().get(0));
                        filters.add(item);
                        break;
                    }
                }
            }
        }
    }

    /**
     * 设置地址控件属性过滤值
     *
     * @param filters
     * @param filterVO
     * @param propertyCode
     */
    private void setAddressPropertyFilter(List<FilterExpression> filters, FilterVO filterVO, String propertyCode) {
        FilterExpression.Item item;
        if (filterVO.getPropertyType() == BizPropertyType.ADDRESS) {
            String address = filterVO.getPropertyValue().get(0);
            Map<String, String> addressMap = JSON.parseObject(address, new TypeReference<Map<String, String>>() {
            });
            String provinceAdcode = addressMap.get("provinceAdcode");
            String cityAdcode = addressMap.get("cityAdcode");
            String districtAdcode = addressMap.get("districtName");
            if (StringUtils.isNotEmpty(provinceAdcode)) {
                item = Q.it(propertyCode, FilterExpression.Op.Like, provinceAdcode);
                filters.add(item);
            }
            if (StringUtils.isNotEmpty(cityAdcode)) {
                item = Q.it(propertyCode, FilterExpression.Op.Like, cityAdcode);
                filters.add(item);
            }
            if (StringUtils.isNotEmpty(districtAdcode)) {
                item = Q.it(propertyCode, FilterExpression.Op.Like, districtAdcode);
                filters.add(item);
            }
        } else {
            if (StringUtils.isNotBlank(filterVO.getPropertyValue().get(0))) {
                item = Q.it(propertyCode, FilterExpression.Op.Like, filterVO.getPropertyValue().get(0));
                filters.add(item);
            }
        }
    }


    /**
     * 生成关联查询/反关联查询可见过滤条件条件
     *
     * @param filterVOs        查询条件
     * @param visibleCondition 查询条件
     * @param filters          过滤
     */
    private void createVisibleFilter(List<FilterVO> filterVOs, List<BizQueryConditionModel> visibleCondition, List<FilterExpression> filters) {
        for (FilterVO filterVO : filterVOs) {
            boolean machAble = false;
            if (BizPropertyType.WORK_SHEET.equals(filterVO.getPropertyType())) {
                if (CollectionUtils.isEmpty(filterVO.getPropertyValue())) {
                    continue;
                }
                FilterExpression.Item items = Q.it(filterVO.getPropertyCode(), FilterExpression.Op.Eq, filterVO.getPropertyValue().get(0));
                filters.add(items);
            }
            if (CollectionUtils.isNotEmpty(visibleCondition)) {
                for (BizQueryConditionModel condition : visibleCondition) {
                    FilterExpression.Item item = null;
                    if (filterVO.getPropertyCode().equals(condition.getPropertyCode())) {
                        machAble = true;
                        if (CollectionUtils.isEmpty(filterVO.getPropertyValue())) {
                            continue;
                        }
                        if (condition.getPropertyType().equals(BizPropertyType.SELECTION)) {
                            List<String> defaults = filterVO.getDefaultProperties();
                            if (defaults.contains(filterVO.getPropertyCode()) &&
                                    (DefaultPropertyType.OWNER_DEPT_ID.getCode().equals(filterVO.getPropertyCode()) ||
                                            DefaultPropertyType.CREATED_DEPT_ID.getCode().equals(filterVO.getPropertyCode()))) {
                                //创建人部门过滤权限
                                List<String> departmentIds = Lists.newArrayList();
                                for (String deptId : filterVO.getPropertyValue()) {
                                    List<String> deptIds = Lists.newArrayList();
                                    List<DepartmentModel> departmentModels = getOrganizationFacade().getDepartmentsChildList(departmentIds, true);
                                    if (CollectionUtils.isNotEmpty(departmentModels)) {
                                        departmentModels.stream().forEach(departmentModel -> {
                                            deptIds.add(departmentModel.getId());
                                        });
                                        deptIds.add(deptId);
                                        departmentIds.addAll(deptIds);
                                    } else {
                                        departmentIds.add(deptId);
                                    }
                                }
                                item = Q.it(condition.getPropertyCode(), FilterExpression.Op.In, departmentIds);
                                if (CollectionUtils.isNotEmpty(departmentIds)) {
                                    filters.add(item);
                                }
                                break;
                            }

                            if (defaults.contains(filterVO.getPropertyCode())) {
                                item = Q.it(condition.getPropertyCode(), FilterExpression.Op.In, filterVO.getPropertyValue());
                                if (CollectionUtils.isNotEmpty(filterVO.getPropertyValue())) {
                                    filters.add(item);
                                }
                                break;
                            }
                            List<FilterExpression> filterTemplates = new ArrayList<>();
                            for (String s : filterVO.getPropertyValue()) {
                                filterTemplates.add(Q.it(filterVO.getPropertyCode(), FilterExpression.Op.Like, s));
                            }
                            if (CollectionUtils.isNotEmpty(filterTemplates)) {
                                if (filterTemplates.size() == 1) {
                                    filters.add(filterTemplates.get(0));
                                } else {
                                    filters.add(Q.or(filterTemplates));
                                }
                            }
                            break;
                        }
                        if (condition.getDisplayType() != null && condition.getDisplayType().equals(DisplayType.CHECKBOX)) {
                            item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Like, filterVO.getPropertyValue());
                            filters.add(item);
                            break;
                        }
                        if (condition.getDisplayType() != null && condition.getDisplayType().equals(DisplayType.SELECT)) {
                            //修改  多选精确查询
                            List<String> propertyValue = filterVO.getPropertyValue();
                            if (CollectionUtils.isNotEmpty(propertyValue) && propertyValue.size() > 1) {
                                String regex = generateRegex(propertyValue);
                                FilterExpression.Item it = Q.it(condition.getPropertyCode(), FilterExpression.Op.Reg, regex);
                                filters.add(it);
                                break;
                            }
                            //修改 修改  多选精确查询
                            item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Eq, filterVO.getPropertyValue());
                            filters.add(item);
                            break;
                        }
                        if (condition.getDisplayType() != null && condition.getDisplayType().equals(DisplayType.RANGE) || condition.getPropertyType().equals(BizPropertyType.NUMERICAL) || condition.getPropertyType().equals(BizPropertyType.DATE)) {
                            createScopeFilter(condition, filterVO, filters, false);
                            break;
                        }
                        if (condition.getPropertyType().equals(BizPropertyType.LOGICAL)) {
                            item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Eq, filterVO.getPropertyValue().get(0));
                            filters.add(item);
                            break;
                        }
                        if (condition.getDisplayType() != null && condition.getDisplayType().equals(DisplayType.INPUT)) {
                            /*
                             * 地址控件类型查询条件，根据编码查询
                             * 格式:
                             *    省
                             *    省-市
                             *    省-市-区
                             */
                            setAddressPropertyFilter(filters, filterVO, condition.getPropertyCode());
                            break;
                        }
                        item = Q.it(condition.getPropertyCode(), FilterExpression.Op.Eq, filterVO.getPropertyValue().get(0));
                        filters.add(item);
                        break;
                    }
                }
            }

            if (!machAble) {
                if (filterVO.getPropertyCode().equals(DefaultPropertyType.SEQUENCE_STATUS.getCode())) {
                    if (CollectionUtils.isNotEmpty(filterVO.getPropertyValue())) {
                        filters.add(Q.it(filterVO.getPropertyCode(), FilterExpression.Op.In, filterVO.getPropertyValue()));
                    }
                    continue;
                }
                List<String> defaultCodes = filterVO.getDefaultProperties();
                if (defaultCodes.contains(filterVO.getPropertyCode())) {
                    if (filterVO.getPropertyType() == BizPropertyType.SHORT_TEXT && CollectionUtils.isNotEmpty(filterVO.getPropertyValue())) {
                        filters.add(Q.it(filterVO.getPropertyCode(), FilterExpression.Op.Like, filterVO.getPropertyValue().get(0)));
                    } else if (filterVO.getPropertyType() == BizPropertyType.ID && CollectionUtils.isNotEmpty(filterVO.getPropertyValue())) {
                        filters.add(Q.it(filterVO.getPropertyCode(), FilterExpression.Op.In, filterVO.getPropertyValue()));
                    } else {
                        if (CollectionUtils.isNotEmpty(filterVO.getPropertyValue())) {
                            filters.add(Q.it(filterVO.getPropertyCode(), FilterExpression.Op.Eq, filterVO.getPropertyValue().get(0)));
                        }
                    }
                    continue;
                }
                if (log.isDebugEnabled()) {
                    log.debug("查询条件不匹配: {}", filterVO.getPropertyCode());
                }
            }
        }
    }

    /**
     * 获取范围查询条件
     *
     * @param condition 查询条件
     * @param filterVO  查询条件
     * @param filters   过滤
     * @param isDefault 是否默认
     */
    private void createScopeFilter(BizQueryConditionModel condition, FilterVO filterVO, List<FilterExpression> filters, Boolean isDefault) {
        //默认值情况
        FilterExpression.Item itemStart = null;
        FilterExpression.Item itemEnd = null;
        List<String> values = filterVO == null ? null : filterVO.getPropertyValue();
        Object startValue = null;
        Object endValue = null;
        if (CollectionUtils.isEmpty(values)) {
            startValue = isDefault ? (condition.getStartValue() == null ? null : ("".equals(condition.getStartValue()) ? null : condition.getStartValue())) : (values == null ? null : values.get(0));
            endValue = isDefault ? (condition.getEndValue() == null ? null : ("".equals(condition.getEndValue()) ? null : condition.getEndValue())) : (values == null ? null : values.get(1));
        } else {
            if (values.size() == 1) {
                startValue = isDefault ? (condition.getStartValue() == null ? null : ("".equals(condition.getStartValue()) ? null : condition.getStartValue())) : (values == null ? null : values.get(0));
                endValue = isDefault ? (condition.getEndValue() == null ? null : ("".equals(condition.getEndValue()) ? null : condition.getEndValue())) : (values == null ? null : values.get(0));
            } else if (values.size() == 2) {
                if (isDefault && (!condition.getDateType().equals(0))) {
                    startValue = values == null ? null : values.get(0);
                    endValue = values == null ? null : values.get(1);
                } else if (!isDefault) {
                    startValue = values == null ? null : values.get(0);
                    endValue = values == null ? null : values.get(1);
                } else if (isDefault && condition.getDateType().equals(0)) {
                    startValue = condition.getStartValue() == null ? null : ("".equals(condition.getStartValue()) ? null : condition.getStartValue());
                    endValue = condition.getEndValue() == null ? null : ("".equals(condition.getEndValue()) ? null : condition.getEndValue());
                }

            }
        }

        if (isDefault && condition.getPropertyType() == BizPropertyType.DATE) {
            List<String> list = parseHiddrenDate(startValue, endValue);
            if (CollectionUtils.isNotEmpty(list)) {
                startValue = list.get(0);
                endValue = list.get(1);
            }
        }
        if (null != startValue) {
            itemStart = Q.it(condition.getPropertyCode(), FilterExpression.Op.Gte, startValue);
        }
        if (null != endValue) {
            itemEnd = Q.it(condition.getPropertyCode(), FilterExpression.Op.Lte, endValue);
        }
        if (itemStart != null && itemEnd != null) {
            FilterExpression.And and = Q.and(itemStart, itemEnd);
            filters.add(and);
            return;
        }
        if (itemStart == null && itemEnd == null) {
            return;
        }
        filters.add(itemStart == null ? itemEnd : itemStart);
    }

    private List<String> parseHiddrenDate(Object startValue, Object endValue) {
        if (null != startValue && null != endValue) {
            List<Object> list = new ArrayList<>();
            list.add(startValue);
            list.add(endValue);
            String join = Joiner.on(";").skipNulls().join(list);
            String value = PropertyValidateHelper.parseDate(join);
            List<String> strings = new ArrayList<>(Arrays.asList(value.split(";")));
            return strings;
        }
        return null;
    }


    protected ResponseResult<FileOperationResult> secondImportData(FileOperationResult operationResult) {
        String uid = getUserId();
        UserModel user = getOrganizationFacade().getUser(uid);
        String corpId = user.getCorpId();

        boolean success = true;
        boolean b = operationResult == null;
        if (b) {
            throw new ServiceException(ErrCode.BIZ_QUERY_DATA_EMPTY);
        }

        boolean empty = CollectionUtils.isEmpty(operationResult.getHeadColumns());
        boolean empty1 = CollectionUtils.isEmpty(operationResult.getSecondImportData());
        if (empty || empty1) {
            throw new ServiceException(ErrCode.BIZ_QUERY_DATA_EMPTY);
        }
        List<BizQueryColumnModel> headColumns = operationResult.getHeadColumns();
        List<Map<String, Object>> secondImportData = Lists.newArrayList();
        List<Map<String, Object>> data = operationResult.getSecondImportData();
        secondImportData.addAll(data);
        //在内存中存入子表code和properties的关系，减少查询次数--Map<String,Object>
        Map<String, List<BizQueryChildColumnModel>> childMap = Maps.newHashMap();
        //在内存中存入code和headColumn的关系
        Map<String, BizQueryColumnModel> mainMap = Maps.newHashMap();
        for (BizQueryColumnModel columnModel : headColumns) {
            BizPropertyType propertyType = columnModel.getPropertyType();
            boolean equals = Objects.equals(propertyType, BizPropertyType.CHILD_TABLE);
            String code = columnModel.getPropertyCode();
            if (equals) {

                List<BizQueryChildColumnModel> childColumns = columnModel.getChildColumns();
                childMap.put(code, childColumns);
            } else {
                mainMap.put(code, columnModel);
            }
        }

        BizQueryColumnModel columnModel = headColumns.get(0);
        String schemaCode = columnModel.getSchemaCode();
        BizSchemaModel bizSchemaModel = getAppManagementFacade().getBizSchemaBySchemaCode(schemaCode, true);
        List<BizPropertyModel> properties = bizSchemaModel.getProperties();
        List<BizObjectModel> bizObjectModels = Lists.newArrayList();

        //校验选人数据项是否都改变
        for (Map<String, Object> map : secondImportData) {
            if (MapUtils.isNotEmpty(map)) {
                for (String key : map.keySet()) {
                    BizPropertyModel bizProperty = properties.stream().filter(t -> t.getCode().equals(key)).findAny().orElse(null);
                    if (bizProperty == null) {
                        continue;
                    }
                    Boolean propertyEmpty = bizProperty.getPropertyEmpty();
                    BizPropertyType propertyType = bizProperty.getPropertyType();
                    boolean equals3 = Objects.equals(propertyType, BizPropertyType.WORK_SHEET);
                    boolean equals = Objects.equals(propertyType, BizPropertyType.SELECTION);
                    boolean equals1 = Objects.equals(propertyType, BizPropertyType.CHILD_TABLE);
                    if (equals3) {
                        Object o = map.get(key);
                        if (Objects.isNull(o)) {
                            continue;
                        }
                        Map<String, Object> biz = (Map<String, Object>) o;
                        String id = Objects.isNull(biz.get("id")) ? null : biz.get("id").toString();
                        map.put(key, id);
                        continue;
                    }
                    if (equals) {
                        success = verifySelections(map, key, null, propertyType, mainMap, success, propertyEmpty, corpId);
                        if (!success) {
                            return getErrResponseResult(operationResult, ErrCode.BIZ_QUERY_DATA_VALID_FAIL.getErrCode(), ErrCode.BIZ_QUERY_DATA_VALID_FAIL.getErrMsg());
                        }
                    } else {
                        if (equals1) {
                            String code = bizProperty.getCode();
                            if (MapUtils.isNotEmpty(childMap)) {
                                List<BizQueryChildColumnModel> childColumnModels = childMap.get(code);
                                if (CollectionUtils.isNotEmpty(childColumnModels)) {
                                    for (BizQueryChildColumnModel bizQueryChildColumnModel : childColumnModels) {
                                        String childPropertyCode = bizQueryChildColumnModel.getPropertyCode();
                                        BizSchemaModel bizSchemaBySchemaCode = getAppManagementFacade().getBizSchemaBySchemaCode(code, true);
                                        List<BizPropertyModel> properties1 = bizSchemaBySchemaCode.getProperties();
                                        BizPropertyType childPropertyType = bizQueryChildColumnModel.getPropertyType();
                                        List<BizPropertyModel> collect = properties1.stream().filter(propertyModel -> Objects.equals(propertyModel.getCode(), childPropertyCode)).collect(Collectors.toList());
                                        BizPropertyModel propertyModel = collect.get(0);
                                        Boolean propertyEmpty1 = propertyModel.getPropertyEmpty();
                                        boolean equals4 = Objects.equals(childPropertyType, BizPropertyType.WORK_SHEET);
                                        if (equals4) {
                                            Object o = map.get(key);
                                            if (Objects.isNull(o)) {
                                                continue;
                                            }
                                            List<Map<String, Object>> child = (List<Map<String, Object>>) o;
                                            for (Map<String, Object> objectMap : child) {
                                                if (MapUtils.isEmpty(objectMap)) {
                                                    continue;
                                                }
                                                objectMap.put(childPropertyCode, (Objects.isNull(objectMap.get(childPropertyCode)) ? null : ((Map<String, Object>) objectMap.get(childPropertyCode)).get("id")));
                                            }
                                        }
                                        boolean equals2 = Objects.equals(childPropertyType, BizPropertyType.SELECTION);
                                        if (equals2) {
                                            success = verifySelections(map, code, childPropertyCode, propertyType, null, success, propertyEmpty1, corpId);
                                            if (!success) {
                                                return getErrResponseResult(operationResult, ErrCode.BIZ_QUERY_DATA_VALID_FAIL.getErrCode(), ErrCode.BIZ_QUERY_DATA_VALID_FAIL.getErrMsg());
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                Map<String, Object> importData = Maps.newHashMap();
                importData.putAll(map);
                Object owner = importData.get("owner");
                if (Objects.nonNull(owner)) {
                    List<SelectionValue> owner1 = (List<SelectionValue>) owner;
                    SelectionValue selectionValue = owner1.get(0);
                    if (selectionValue != null && StringUtils.isNotEmpty(selectionValue.getId())) {
                        String id = selectionValue.getId();
                        importData.put("owner", id);
                    }
                }
                BizObjectModel bizObject = new BizObjectModel(schemaCode, importData, false);
                if (bizObject != null) {
                    bizObject.setSequenceStatus(SequenceStatus.COMPLETED.toString());
                    bizObjectModels.add(bizObject);
                }
            }
        }

        if (CollectionUtils.isNotEmpty(bizObjectModels)) {
            String queryField = operationResult.getQueryField();
            operationResult.setSuccessCount(bizObjectModels.size());
            log.info("==================批量更新========成功导入={}条,bizObjects={}", bizObjectModels.size(), JSONObject.toJSONString(bizObjectModels));
            getBizObjectFacade().addBizObjects(getUserId(), bizObjectModels, queryField);
        } else {
            return getErrResponseResult(operationResult, ErrCode.BIZ_QUERY_DATA_VALID_FAIL.getErrCode(), ErrCode.BIZ_QUERY_DATA_VALID_FAIL.getErrMsg());

        }
        return getOkResponseResult(null, "成功导入");
    }

    private boolean verifySelections(Map<String, Object> map, String code, String childPropertyCode, BizPropertyType propertyType, Map<String, BizQueryColumnModel> mainMap, boolean success, boolean notEmpty, String corpId) {
        boolean empty = MapUtils.isEmpty(map);
        if (empty) {
            return false;
        }
        Boolean defaultProperty = false;
        if (MapUtils.isNotEmpty(mainMap)) {
            BizQueryColumnModel columnModel = mainMap.get(code);
            defaultProperty = columnModel.getDefaultProperty();
        }
        boolean equals = Objects.equals(propertyType, BizPropertyType.SELECTION);
        boolean equals1 = Objects.equals(propertyType, BizPropertyType.CHILD_TABLE);
        if (equals) {
            Object o = map.get(code);
            if (Objects.nonNull(o)) {
                List<LinkedHashMap<String, Object>> selectionValues = (List<LinkedHashMap<String, Object>>) o;
                if (CollectionUtils.isEmpty(selectionValues) && notEmpty) {
                    return false;
                } else {
                    //当为系统默认数据项，则返回id，否则返回原有数据
                    //List<String> ids = Lists.newArrayList();
                    List<SelectionValue> selectionValues1 = Lists.newArrayList();
                    for (LinkedHashMap<String, Object> selectMap : selectionValues) {
                        SelectionValue selectionValue = new SelectionValue();
                        Object id1 = selectMap.get("id");
                        Object type = selectMap.get("type");
                        Integer integer = Objects.isNull(type) ? null : Integer.parseInt(type.toString());
                        Object excelType = selectMap.get("excelType");
                        Integer integer1 = Objects.isNull(excelType) ? null : Integer.parseInt(excelType.toString());
                        String uid = Objects.isNull(id1) ? "" : id1.toString();
                        if (integer != null) {
                            switch (integer) {
                                case 1:
                                    DepartmentModel department = getOrganizationFacade().getDepartment(uid);
                                    if (department == null && notEmpty) {
                                        return false;
                                    }
                                    if (department == null && (Objects.equals(integer1, 1) || Objects.equals(integer1, 2))) {
                                        return false;
                                    }
                                    if (department != null) {
                                        selectionValue.setType(UnitType.DEPARTMENT);
                                        selectionValue.setId(uid);
                                        selectionValue.setName(department.getName());
                                        selectionValues1.add(selectionValue);
                                    }
                                    break;
                                case 3:
                                    UserModel user = getOrganizationFacade().getUser(uid);
                                    boolean b = user == null || Objects.equals(user.getStatus(), UserStatus.DISABLE);
                                    if (b && notEmpty) {
                                        return false;
                                    }
                                    if (b && (Objects.equals(integer1, 1) || Objects.equals(integer1, 2))) {
                                        return false;
                                    }
                                    if (user != null && Objects.equals(user.getStatus(), UserStatus.ENABLE)) {
                                        if (MapUtils.isNotEmpty(mainMap) && defaultProperty) {
                                            selectionValue.setType(UnitType.USER);
                                            selectionValue.setId(uid);
                                            selectionValue.setName(user.getName());
                                            selectionValues1.add(selectionValue);
                                        } else {
                                            selectionValue.setType(UnitType.USER);
                                            selectionValue.setId(uid);
                                            selectionValue.setName(user.getName());
                                            selectionValues1.add(selectionValue);
                                        }
                                    }
                                    break;
                            }
                        }
                    }
                    if ((MapUtils.isNotEmpty(mainMap) && defaultProperty && selectionValues.size() == 1)) {
                        map.put(code, selectionValues1);
                    } else {
                        List<String> idList = Lists.newArrayList();
                        if (CollectionUtils.isNotEmpty(selectionValues1)) {
                            for (SelectionValue selectionValue : selectionValues1) {
                                String id = selectionValue.getId();
                                if (StringUtils.isNotEmpty(id)) {
                                    idList.add(id);
                                }
                            }
                        }
                        if (CollectionUtils.isNotEmpty(idList)) {
                            map.put(code, selectionValues1);
                        } else {
                            map.put(code, null);
                        }
                    }
                }
            }

        } else {
            if (equals1) {
                Object o = map.get(code);
                if (Objects.nonNull(o)) {
                    List<Map<String, Object>> childs = (List<Map<String, Object>>) o;
                    if (CollectionUtils.isNotEmpty(childs)) {
                        for (Map<String, Object> childMaps : childs) {
                            Object o1 = childMaps.get(childPropertyCode);
                            if (Objects.nonNull(o1)) {
                                List<LinkedHashMap<String, Object>> selectionValues = (List<LinkedHashMap<String, Object>>) o1;
                                if (CollectionUtils.isNotEmpty(selectionValues)) {
                                    List<SelectionValue> selectionValueList = Lists.newArrayList();
                                    for (LinkedHashMap<String, Object> selectMap : selectionValues) {
                                        SelectionValue selectionValue = new SelectionValue();
                                        Object id1 = selectMap.get("id");
                                        Object type = selectMap.get("type");
                                        Object excelType = selectMap.get("excelType");
                                        Integer integer1 = Objects.isNull(excelType) ? null : Integer.parseInt(excelType.toString());
                                        Integer integer = Objects.isNull(type) ? null : Integer.parseInt(type.toString());
                                        String uid = Objects.isNull(id1) ? "" : id1.toString();
                                        if (integer != null) {
                                            switch (integer) {
                                                case 1:
                                                    DepartmentModel department = getOrganizationFacade().getDepartment(uid);
                                                    if (department == null && notEmpty) {
                                                        return false;
                                                    }
                                                    if (department == null && (Objects.equals(integer1, 1) || Objects.equals(integer1, 2))) {
                                                        return false;
                                                    }
                                                    if (department != null) {
                                                        selectionValue.setType(UnitType.DEPARTMENT);
                                                        selectionValue.setId(uid);
                                                        selectionValue.setName(department.getName());
                                                        selectionValueList.add(selectionValue);
                                                    }
                                                    break;
                                                case 3:
                                                    UserModel user = getOrganizationFacade().getUser(uid);
                                                    boolean b = user == null || Objects.equals(user.getStatus(), UserStatus.DISABLE);
                                                    if (b && notEmpty) {
                                                        return false;
                                                    }
                                                    if (b && (Objects.equals(integer1, 1) || Objects.equals(integer1, 2))) {
                                                        return false;
                                                    }
                                                    if (user != null && Objects.equals(user.getStatus(), UserStatus.ENABLE)) {
                                                        if (MapUtils.isNotEmpty(mainMap) && defaultProperty) {
                                                            selectionValue.setType(UnitType.USER);
                                                            selectionValue.setId(uid);
                                                            selectionValue.setName(user.getName());
                                                            selectionValueList.add(selectionValue);
                                                        } else {
                                                            selectionValue.setType(UnitType.USER);
                                                            selectionValue.setId(uid);
                                                            selectionValue.setName(user.getName());
                                                            selectionValueList.add(selectionValue);
                                                        }
                                                    }
                                                    break;
                                            }
                                        }
                                    }
                                    List<String> idList = Lists.newArrayList();
                                    if (CollectionUtils.isNotEmpty(selectionValueList)) {
                                        for (SelectionValue selectionValue : selectionValueList) {
                                            String id = selectionValue.getId();
                                            if (StringUtils.isNotEmpty(id)) {
                                                idList.add(id);
                                            }
                                        }
                                    }
                                    if (CollectionUtils.isNotEmpty(idList)) {
                                        childMaps.put(childPropertyCode, selectionValueList);
                                    } else {
                                        childMaps.put(childPropertyCode, null);
                                    }
                                } else {
                                    if (CollectionUtils.isEmpty(selectionValues) && notEmpty) {
                                        return false;
                                    } else {
                                        childMaps.put(childPropertyCode, null);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return success;
    }


    /**
     * api ： 表单子表导入二次重试api
     *
     * @param operationResult
     * @return
     */
    protected ResponseResult<FileOperationResult> getSecondImportDatas(FileOperationResult operationResult) {
        List<Map<String, Object>> subSecondData = operationResult.getSecondImportData();
        if (CollectionUtils.isEmpty(subSecondData)) {
            return getErrResponseResult(null, -1L, "没有需要重试的数据");
        }
        List<BizQueryColumnModel> headColumns = operationResult.getHeadColumns();
        if (CollectionUtils.isEmpty(headColumns)) {
            return getErrResponseResult(null, -1L, "请传入标题字段");
        }
        String id = getUserId();
        UserModel user = getOrganizationFacade().getUser(id);
        String corpId = user.getCorpId();
        BizObjectHelper bizObjectHelper = new BizObjectHelper(getWorkflowInstanceFacade(), getBizObjectFacade(),
                getOrganizationFacade(), dubboConfigService, getAppManagementFacade(), getSystemManagementFacade());
        return bizObjectHelper.getSecondImportDatas(operationResult, corpId);

    }

    private class GetBizQueryOptions {
        private BizPropertyModel bizProperty;
        private Map<String, Object> multWorkMap;
        private BizObjectQueryModel.Options options;
        private List<String> queryCodes;

        public GetBizQueryOptions(BizPropertyModel bizProperty, Map<String, Object> multWorkMap) {
            this.bizProperty = bizProperty;
            this.multWorkMap = multWorkMap;
        }

        public BizObjectQueryModel.Options getOptions() {
            return options;
        }

        public List<String> getQueryCodes() {
            return queryCodes;
        }

        public GetBizQueryOptions invoke() {
            options = new BizObjectQueryModel.Options();
            queryCodes = Lists.newArrayList();
            queryCodes.add("id");
            if (Objects.nonNull(multWorkMap.get(bizProperty.getCode() + "_mappingKeys"))) {
                String mappingKeys = (String) multWorkMap.get(bizProperty.getCode() + "_mappingKeys");

                if (StringUtils.isNotEmpty(mappingKeys)) {
                    String mappingKeyStrs[] = mappingKeys.split(";");
                    for (String mappingKey : mappingKeyStrs) {
                        queryCodes.add(mappingKey);
                    }
                }
            }
            options.setCustomDisplayColumns(queryCodes);
            options.setQueryDisplayType(QueryDisplayType.APPEND);
            return this;
        }
    }


    //控件匹配与否信息
    //@Param T 控件值，不同控件类型不一样
    class CompMatchInfo<T> {
        private T value;//控件显示值
        private Boolean marked;//控件标红与否

        public CompMatchInfo(T value, Boolean marked) {
            this.value = value;
            this.marked = marked;
        }

        public T getValue() {
            return value;
        }

        public void setValue(T value) {
            this.value = value;
        }

        public Boolean getMarked() {
            return marked;
        }

        public void setMarked(Boolean marked) {
            this.marked = marked;
        }
    }

    static class CompProperty {
        private String key;
        private Integer type;
        private Integer width;// "width":150,
        private String parentKey;//       "parentKey":"Sheet1604541828261"
        private Option options;//

        static class Option {
            private String name;//"":"省份",
            private String name_i18n;
            private Boolean visible;//      "":true,
            private String style;//      "style":"",
            private String tips;//        "tips":"",
            private String dataItemName;    //  "":"",
            private String displayFormula;//      "":"",
            private String onChange;  //   "":"",
            private String requiredFormula;//     "":"",
            private Boolean readonlyFormula;//       "":false,
            private String defaultValue;//   "":"河南",
            private String options;//    "options":"河南;河北",
            private String widgetType;//    "widgetType":"",
            private Boolean displayEmpty;//   "displayEmpty":true,
            private String emptyValue;//    "emptyValue":"请选择",
            private Boolean multi;//   "multi":false,
            private Integer width; //    "width":150

            public String getName() {
                return name;
            }

            public void setName(String name) {
                this.name = name;
            }

            public String getName_i18n() {
                return name_i18n;
            }

            public void setName_i18n(String name_i18n) {
                this.name_i18n = name_i18n;
            }

            public Boolean getVisible() {
                return visible;
            }

            public void setVisible(Boolean visible) {
                this.visible = visible;
            }

            public String getStyle() {
                return style;
            }

            public void setStyle(String style) {
                this.style = style;
            }

            public String getTips() {
                return tips;
            }

            public void setTips(String tips) {
                this.tips = tips;
            }

            public String getDataItemName() {
                return dataItemName;
            }

            public void setDataItemName(String dataItemName) {
                this.dataItemName = dataItemName;
            }

            public String getDisplayFormula() {
                return displayFormula;
            }

            public void setDisplayFormula(String displayFormula) {
                this.displayFormula = displayFormula;
            }

            public String getOnChange() {
                return onChange;
            }

            public void setOnChange(String onChange) {
                this.onChange = onChange;
            }

            public String getRequiredFormula() {
                return requiredFormula;
            }

            public void setRequiredFormula(String requiredFormula) {
                this.requiredFormula = requiredFormula;
            }

            public Boolean getReadonlyFormula() {
                return readonlyFormula;
            }

            public void setReadonlyFormula(Boolean readonlyFormula) {
                this.readonlyFormula = readonlyFormula;
            }

            public String getDefaultValue() {
                return defaultValue;
            }

            public void setDefaultValue(String defaultValue) {
                this.defaultValue = defaultValue;
            }

            public String getOptions() {
                return options;
            }

            public void setOptions(String options) {
                this.options = options;
            }

            public String getWidgetType() {
                return widgetType;
            }

            public void setWidgetType(String widgetType) {
                this.widgetType = widgetType;
            }

            public Boolean getDisplayEmpty() {
                return displayEmpty;
            }

            public void setDisplayEmpty(Boolean displayEmpty) {
                this.displayEmpty = displayEmpty;
            }

            public String getEmptyValue() {
                return emptyValue;
            }

            public void setEmptyValue(String emptyValue) {
                this.emptyValue = emptyValue;
            }

            public Boolean getMulti() {
                return multi;
            }

            public void setMulti(Boolean multi) {
                this.multi = multi;
            }

            public Integer getWidth() {
                return width;
            }

            public void setWidth(Integer width) {
                this.width = width;
            }
        }

        public String getKey() {
            return key;
        }

        public void setKey(String key) {
            this.key = key;
        }

        public Integer getType() {
            return type;
        }

        public void setType(Integer type) {
            this.type = type;
        }

        public Integer getWidth() {
            return width;
        }

        public void setWidth(Integer width) {
            this.width = width;
        }

        public String getParentKey() {
            return parentKey;
        }

        public void setParentKey(String parentKey) {
            this.parentKey = parentKey;
        }

        public Option getOptions() {
            return options;
        }

        public void setOptions(Option options) {
            this.options = options;
        }
    }

}
